Setting a Counter (Code Here)

T

Tim Leach

I am using the following code in the Current Event of a form. What I am
trying to do is flash a message in a text box 5 times. The message is in
red on a white background, after the fifth time I want to turn the text to
white so it can not be seen. I also have a close form macro in the On
Click event of the text box to exit the form. It exits correctly if the
text box is clicked and it flashes correctly in color and time, but it just
keeps flashing and does not stop at 5. What am I doing wrong?


Private Sub Form_Current()
Dim Counter As Integer
Counter = 0
If Counter < 5 Then
Me.TimerInterval = 800
Me.Label27.ForeColor = vbWhite
Me.TimerInterval = 800
Me.Label27.ForeColor = vbRed
Counter = Counter + 1
Else
Me.TimerInterval = 0
Me.Label27.ForeColor = vbWhite


End If
End Sub

Thanks Tim
 
J

Jim/Chris

How about this?
Private Sub Form_Current()
Dim Counter As Integer
Counter = 0 Do Until Counter = 5
Me.TimerInterval = 800
Me.Label27.ForeColor = vbWhite
Me.TimerInterval = 800
Me.Label27.ForeColor = vbRed
Counter = Counter + 1 Loop
Else
Me.TimerInterval = 0
Me.Label27.ForeColor = vbWhite


End If
End Sub

Good Luck Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top