Please help me with this
I grabbed the following code from a website, it can be used as a timer. It works exactly as intended.
My question is which of the variables or procedure names need to be changed to have two or more timers like this coexist in the same workbook.
I highlighted in bold what I am guessing needs to be changed.
*********************************************************
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
Sub StartTimer()
TimerSeconds = 1 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
'
' The procedure is called by Windows. Put your
' timer-related code here.
'
End Sub
**********************************************************
Here are some comments that were included with the code from the website.
The procedure TimerProc will be called by Windows every time the timer pops. You can name this procedure anything you want, but you must declare the argument variables exactly as shown in the example. If you change the name of the procedure, be sure to change the name in the call to SetTimer as well.
nIDEvent The value returned by SetTimer to the TimerID variable. If you have made more than one call to SetTimer, you can examine the nIDEvent argument to determine which call SetTimer to resulted in the procedure being called.
Thank you for your help
Bookmarks