Option Explicit
'
' <CountDownTimer.cls>
'
' Author: Dave Sell
'
' References:
'
' - vbAPITimerTools (vbAPITimer.dll)
'
Public Event Refresh()
Public Event Finsihed()
Public Event Started()
'
Private WithEvents m_Timer As APITimer
'
Private m_CountDownInterval As Long
Private m_ActiveIntervals As Long
Private m_blnRunning As Boolean
'
Private Sub Class_Initialize()
Set m_Timer = New APITimer
m_CountDownInterval = 0
m_ActiveIntervals = 0
m_blnRunning = False
End Sub
Public Property Let Interval(ByVal vNewValue As Variant)
m_CountDownInterval = vNewValue
End Property
Public Property Get Interval() As Variant
Interval = m_CountDownInterval
End Property
Private Sub IncrementCountDown(lngIntervals As Long)
'
If Not m_blnRunning Then
m_Timer.StartTimer m_CountDownInterval
m_blnRunning = True
RaiseEvent Started
End If
'
m_ActiveIntervals = m_ActiveIntervals + lngIntervals
'
End Sub
Public Sub Increment()
IncrementCountDown 1
End Sub
Public Sub MultiIncrement(lngIntervals As Long)
IncrementCountDown lngIntervals
End Sub
Private Sub m_Timer_Refresh()
'
If m_blnRunning = True Then
m_ActiveIntervals = m_ActiveIntervals - 1
RaiseEvent Refresh
End If
'
If m_ActiveIntervals = 0 Then
m_Timer.StopTimer
RaiseEvent Refresh
RaiseEvent Finsihed
m_blnRunning = False
End If
'
'
End Sub
Public Property Get ActiveIntervals() As Variant
ActiveIntervals = m_ActiveIntervals
End Property