RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
May 8, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Allow Interval Greater Than Timer Controls

When you need a timer for a larger interval than the Timer control allows, insert this code into a BAS module. The procedure starts when the timer interval has passed:
Dim lTimerId As Long
Private Declare Function SetTimer Lib "user32" _
(ByVal hWnd As Long, ByVal nIDEvent As _
Long, ByVal uElapse As Long, ByVal _
lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib _
"user32" (ByVal hWnd As Long, ByVal _
nIDEvent As Long) As Long
Private Sub TimerProc(ByVal lHwnd As Long, _
ByVal lMsg As Long, ByVal lTimerId As Long, _
ByVal lTime As Long)
Dim lResult As Long
lResult = StopTimer(lTimerId)
Call InsertYourProcessNameHere
'code to be executed after interval
End Sub
Public Sub StartTimer(lInterval As Long) _
'convert interval to milliseconds prior to
lTimerId = SetTimer(0, 0, lInterval, _
AddressOf TimerProc)
End Sub
Public Function StopTimer(lTimerId As Long) _
As Long
'must pass the TimerId returned by SetTimer
StopTimer = KillTimer(0, lTimerId)
End Function
This call executes the procedure:
Call StartTimer(5000) '5 seconds

You can stop the timer before the interval by calling the StopTimer function.
Alex Whyte
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date