|
|
Title | Use API functions to create a timer that can wait as long as 23 days between events |
Description | A normal Visual Basic Timer control can only wait 65,535 milliseconds or about 65 seconds. This example shows how to use API functions to create a timer that can wait as long as 23 days between events in Visual Basic 6. |
Keywords | Timer, Timer control, time, speed, performance |
Categories | Controls, API |
|
|
The CmdStart button's Click event handler determines whether the timer is running. If the timer is running, the code uses KillTimer to stop it. If the timer is not running, the code uses SetTimer to start it. Because the timer's delay is specified in milliseconds as a long integer, the delay can be more than 23 days.
|
|
Private TimerID As Long
' Start or stop the timer. See also Form_Unload.
Private Sub CmdStart_Click()
Static running As Boolean
Dim pause As Long
If running Then
' Stop the timer.
KillTimer 0, TimerID
CmdStart.Caption = "Start"
RunningLabel.Caption = "Stopped"
Else
' Start the timer.
pause = CLng(PauseText.Text)
TimerID = SetTimer(0, 0, pause, _
AddressOf MyTimer)
CmdStart.Caption = "Stop"
RunningLabel.Caption = "Running"
End If
running = Not running
End Sub
|
|
|
|
|
|