-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimers.cls
66 lines (66 loc) · 1.91 KB
/
Timers.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Timers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Public Event TimerEvent(ByVal Index As Integer)
Private mvarCount As Integer
Private mvarCollection As New Collection
Private mvarKeyClass As Integer
Private mvarTimer As Timer
Private Sub Class_Initialize()
mvarKeyClass = RegisterTimers(Me)
Set mvarTimer = New Timer
End Sub
Private Sub Class_Terminate()
Set mvarTimer = Nothing
Dim tmr As Timer
For Each tmr In mvarCollection
Set tmr = Nothing
Next
Set mvarCollection = Nothing
colTimers.Remove "key:" & mvarKeyClass
End Sub
Public Property Get Timer() As Timer
Set Timer = mvarTimer
End Property
Public Property Set Timer(vData As Timer)
Set mvarTimer = vData
End Property
Property Get Count() As Integer
Count = mvarCount
End Property
Function Add() As Integer
Dim tmr As New Timer
mvarCount = mvarCount + 1
tmr.Index = mvarCount
tmr.ParentKeyClass = mvarKeyClass
mvarCollection.Add tmr
Add = mvarCount
End Function
'Public Function BulkLoad(num As Integer)
' Dim i As Long
' If num > 0 And num < 200 Then
' For i = 0 To num
' Add
' Next
' Else
' Err.Raise vbObjectError, "CTimers.BulkLoad", "No more than 200 times allowed per class"
' End If
'End Function
Public Function Item(ByVal Index As Integer) As Timer
If Index > Count Then Err.Raise vbObjectError, "CTimers.Item", "Timer Index larger than count not Exist"
Set Item = mvarCollection(Index)
End Function
Friend Function RaiseTimer_Event(ByVal Index As Integer)
RaiseEvent TimerEvent(Index)
End Function