Hey all,
I'm trying to create a timer class so I can control when the timer
start and stops. The ideas is to have a form with a start button, and
a stop button.
Start invokes a class method that polls a linked table's data through
a SQL stored procedure.
Stop just stops the process from running.
My issue is the Form_Timer isn't robust enough.
I've tried using the following:
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
Public Sub StartTimer(Time rInterval As Integer)
TimerSeconds = TimerInterval ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf
AlgoProc)
End Sub
Public Sub AlgoProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal
nIDEvent As _
Long, ByVal dwTimer As Long)
' process code here
End Sub
in a bas module but keep getting an invalid use of Addressof error.
Any help/direction would be appreciated.
Thanks,
Adrian
I'm trying to create a timer class so I can control when the timer
start and stops. The ideas is to have a form with a start button, and
a stop button.
Start invokes a class method that polls a linked table's data through
a SQL stored procedure.
Stop just stops the process from running.
My issue is the Form_Timer isn't robust enough.
I've tried using the following:
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
Public Sub StartTimer(Time rInterval As Integer)
TimerSeconds = TimerInterval ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf
AlgoProc)
End Sub
Public Sub AlgoProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal
nIDEvent As _
Long, ByVal dwTimer As Long)
' process code here
End Sub
in a bas module but keep getting an invalid use of Addressof error.
Any help/direction would be appreciated.
Thanks,
Adrian
Comment