I have created a simple class, cTimeUp. I want to call a function in the class every n seconds using a timer, TimerTimeUp on the form.
When I call the class methods from the form they work, when they are called from the timer I get error 424.
Also intelligence does not see the class objects when typing in Sub TimerTimeUp_Timer(), which is consistent with "Object required".
I have searched for a solution without success but I think the cause is to do with scope? I would be grateful for suggestions.
Private Sub Form_Load()
TimerTimeUp.Interval = 1000
TimerTimeUp.Enabled = True
Dim My As cTimeUp
Set My = New cTimeUp
My.SetTime (5)
MsgBox My.IsTimeUp ' This returns True as it should
End Sub
Private Sub TimerTimeUp_Timer()
MsgBox My.IsTimeUp ' This gives run time error 424 when the timer fires
If My.IsTimeUp Then
' Time is up
Debug.Print "Time up " & " at "; Now()
Else
Debug.Print Now()
End If
End Sub
When I call the class methods from the form they work, when they are called from the timer I get error 424.
Also intelligence does not see the class objects when typing in Sub TimerTimeUp_Timer(), which is consistent with "Object required".
I have searched for a solution without success but I think the cause is to do with scope? I would be grateful for suggestions.
Private Sub Form_Load()
TimerTimeUp.Interval = 1000
TimerTimeUp.Enabled = True
Dim My As cTimeUp
Set My = New cTimeUp
My.SetTime (5)
MsgBox My.IsTimeUp ' This returns True as it should
End Sub
Private Sub TimerTimeUp_Timer()
MsgBox My.IsTimeUp ' This gives run time error 424 when the timer fires
If My.IsTimeUp Then
' Time is up
Debug.Print "Time up " & " at "; Now()
Else
Debug.Print Now()
End If
End Sub