PDA

View Full Version : Solved: Flashing text



av8tordude
04-25-2011, 05:28 PM
How can I make this flash faster?

Sub ColChange()
Dim AppTime

If frmActivate.Visible = True 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"
Else
Exit Sub
End If

Simon Lloyd
04-25-2011, 05:43 PM
You would need to use an API timer as the OnTime method is limited to a shortest interval of 1 second.

av8tordude
04-25-2011, 05:53 PM
I found this code and I adapted it to fit my needs. I'm not familiar with API so could you assist with editing this code. Thanks

Kenneth Hobs
04-25-2011, 07:06 PM
Flashing is usually not a good idea.

See Chip Pearson's timer examples. http://www.cpearson.com/excel/ontime.aspx

Since the cpu is multi-processing, some routines will not show a consistent time loop.

Public Apptime As Double

Sub ColChange()

DoEvents
If frmActivate.Visible = True Then
If frmActivate.cmdBuy.ForeColor = vbBlack Then
frmActivate.cmdBuy.ForeColor = vbButtonFace
Else
frmActivate.cmdBuy.ForeColor = vbBlack
End If
Apptime = Now() + (TimeValue("00:00:01") / 4)
Application.OnTime Apptime, "ColChange"
Else
Exit Sub
End If
End Sub

av8tordude
04-25-2011, 08:52 PM
Thank you Ken.