Private bFiring As Boolean
Private bEnabled As Boolean
Private lInterval As Long
' Timer Event
Event TimerFire()
' Friendly Sub used to Raise the Event from the standard module
Friend Sub RaiseTimerEvent()
RaiseEvent TimerFire
End Sub
' Retreive the Timer Control Properties
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
bEnabled = PropBag.ReadProperty("Enabled", True)
lInterval = PropBag.ReadProperty("Interval", 0)
StartTimer
End Sub
' Store the Timer Control Properties
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Enabled", bEnabled)
Call PropBag.WriteProperty("Interval", lInterval)
End Sub
' Stop the Timer if it's going when the control is destroyed
Private Sub UserControl_Terminate()
If bFiring Then
modStopTimer
bFiring = False
End If
End Sub
' Return the Timer Interval
Public Property Get Interval() As Long
Interval = lInterval
End Property
' Set the Timer Interval
Public Property Let Interval(ByVal vNewValue As Long)
lInterval = vNewValue
If lInterval = 0 Then
StopTimer
Else
StartTimer
End If
End Property
' Return the Timers "Enabled" status
Public Property Get Enabled() As Boolean
Enabled = bEnabled
End Property
' Set the Timers "Enabled" status
Public Property Let Enabled(ByVal vNewValue As Boolean)
bEnabled = vNewValue
If Not bEnabled Then
StopTimer
Else
StartTimer
End If
End Property
' Start the Timer (only at runtime)
Private Sub StartTimer()
If Not UserControl.Ambient.UserMode Then Exit Sub
If bEnabled And lInterval > 0 Then
StopTimer
Call modSetTimer(lInterval, Me)
bFiring = True
End If
End Sub
' Stop the Timer (only at runtime)
Private Sub StopTimer()
If Not UserControl.Ambient.UserMode Then Exit Sub
If bFiring Then
Call modStopTimer
End If
bFiring = False
End Sub