Has anybody had any experience with multiple timers using SetTimer API? I can get two timers going but when I kick in the second one the timing speed is doubled. I think the problem is in the TimerProc sub.
Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
If bTimer = True Then
iCounter = iCounter + 1
UserForm1.TextBox1.Text = CStr(iCounter)
End If
Code example of one of the CommandButton subs:
Private Sub cbStartStop2_Click()
If bTimer2 = False Then
lngTimerID2 = SetTimer(0, 0, 1000, AddressOf TimerProc)
If lngTimerID2 = 0 Then
MsgBox “Timer not created. Ending Program”
Exit Sub
End If
bTimer2 = True
cbStartStop2.Caption = “Stop Timer”
Else
lngTimerID2 = KillTimer(0, lngTimerID2)
If lngTimerID2 = 0 Then
MsgBox “Couldn’t kill the timer”
End If
bTimer2 = False
cbStartStop2.Caption = “Start Timer”
End If
End Sub
If bTimer2 = True Then
iCounter2 = iCounter2 + 1
UserForm1.TextBox2.Text = CStr(iCounter2)
End If
End Sub