PDA

View Full Version : Pause blinking caption



av8tordude
04-29-2011, 11:58 AM
When my userform is displayed, this code makes my button blink. What can I do that will allow me to click the button, stop the blinking momentary to run a different code, and then resume blinking?

Sub ColChange()
Dim AppTime

If frmActivate.Visible = True Then
If frmActivate.cmdBuy.Caption = "Buy Now" Then
If frmActivate.cmdBuy.ForeColor = vbBlack Then
frmActivate.cmdBuy.ForeColor = vbButtonFace
Else
frmActivate.cmdBuy.ForeColor = vbBlack
End If
AppTime = Now() + TimeValue("00:00:01")
Application.OnTime AppTime, "ColChange"
ElseIf frmActivate.cmdBuy.Caption = "Register" Then
If frmActivate.cmdBuy.BackColor = vbButtonFace Then
frmActivate.cmdBuy.BackColor = &H80FF80
frmActivate.cmdBuy.ForeColor = vbBlack
Else
frmActivate.cmdBuy.BackColor = vbButtonFace
End If
AppTime = Now() + TimeValue("00:00:01")
Application.OnTime AppTime, "ColChange"
ElseIf frmActivate.cmdBuy.Caption = "Close" Then
frmActivate.cmdBuy.BackColor = vbButtonFace
Else
Exit Sub
End If
End If

Kenneth Hobs
04-29-2011, 12:40 PM
You need to set the last parameter of Ontime to False to stop it. This is why I made AppTime Public in your other thread. http://www.vbaexpress.com/forum/showthread.php?t=37185