Setting a Counter (Code Here)

  • Thread starter Thread starter Tim Leach
  • Start date Start date
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
 
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
 
Back
Top