Hello.
How do you identify which timer called [/COLOR] a timersub ?
:confused:
I have 30 Timers called with SetTimer.
Printable View
Hello.
How do you identify which timer called [/COLOR] a timersub ?
:confused:
I have 30 Timers called with SetTimer.
Thanks, Megatron. No matter it didnn't work! What is the third argument, though? The idevent?
;)
Silly of me to not test every argument.
Sorry, the 2nd argument is the WM_TIMER message. The 3rd argument is the timer ID (the ID you use to distinguish them)
Thanks, Megatron.
I got thrown off when the third argument has 30 values (I didn't realize that I called 30 timers). Then, the id is not 1,2,3,etc. because I forgot the hWnd.
Anyway, I decided to sticking with one timer because 30 is too slow. Thanks anyway, I learned something new.
:)
hehe... Megatron does not get enough sleep :p
Code:'//Put this code under a Form
Option Explicit
Private Sub Form_Load()
'//Create 3 Timer
SetTimer Me.hwnd, 0, 1000, AddressOf TimerProc
SetTimer Me.hwnd, 1, 2000, AddressOf TimerProc
SetTimer Me.hwnd, 2, 3000, AddressOf TimerProc
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'//Kill all 3 timer
KillTimer Me.hwnd, 0
KillTimer Me.hwnd, 1
KillTimer Me.hwnd, 2
End Sub
'//Put this code under a module
Option Explicit
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
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Select Case uElapse
Case 0
Form1.List1.AddItem "Timer 0 callback"
Case 1
Form1.List1.AddItem "Timer 1 callback"
Case 2
Form1.List1.AddItem "Timer 2 callback"
End Select
End Sub
'Code improved by vBulletin Tool (Save as...)