Start and kill a timer using API calls only! Useful when you need timers that can't be placed on a form.
Original Author: Kamilche
The routine that will be called every Timer milliseconds, MUST be placed in a standard module! It can't be placed on a form, or in a class.
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
'Make this a global variable, or site it
'in the same module as MainLoop.
Public Timer as Long
'To set the timer, issue the
'following, where MainLoop
'is the name of the procedure
'to call every 500 milliseconds.
'Note that MainLoop MUST exist
'in a BAS module!
Timer = SetTimer(0, 0, 500, AddressOf MainLoop)
'To kill the timer,
'issue the following:
KillTimer 0, Timer
About this post
Viewed: 77 times
No comments have been added for this post.
You must be logged in to make a comment.