-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTablesClass.cls
142 lines (108 loc) · 3.68 KB
/
TablesClass.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "TablesClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'@Folder("TableManager.Tables")
Option Explicit
Private Const Module_Name As String = "TablesClass."
Private pAllTables As Scripting.Dictionary
Private Sub Class_Initialize()
Debug.Assert Initializing
Set pAllTables = New Scripting.Dictionary
End Sub ' Class_Initialize
Private Function ModuleList() As Variant
ModuleList = Array("TableRoutines.")
End Function ' ModuleList
Public Property Get Count() As Long: Count = pAllTables.Count: End Property
Public Function Tables() As TablesClass
Set Tables = pAllTables
End Function
'@DefaultMember
Public Property Get Item( _
ByVal vIndex As Variant, _
ByVal ModuleName As String _
) As TableClass
'Attribute Item.VB_UserMemId = 0
Const RoutineName As String = Module_Name & "Get Item"
On Error Resume Next
Debug.Assert InScope(ModuleList, ModuleName)
Set Item = pAllTables.Items()(vIndex)
If Err.Number = 0 Then
On Error GoTo 0
Exit Property
End If
On Error Resume Next
Dim TempTable As TableClass
Set TempTable = pAllTables(vIndex)
Set Item = TempTable
If Err.Number <> 0 Then
MsgBox "The Form for " & CStr(vIndex) & " does not exist. Rebuild the Forms.", _
vbOKOnly Or vbExclamation, _
"Form Does Not Exist"
Set Item = Nothing
Exit Property
End If
On Error GoTo 0
Debug.Assert Not Item Is Nothing
'@Ignore LineLabelNotUsed
Done:
Exit Property
'@Ignore LineLabelNotUsed
ErrorHandler:
RaiseError Err.Number, Err.Source, RoutineName, Err.Description
End Property
Public Sub Add( _
ByVal Tbl As TableClass, _
ByVal ModuleName As String)
' Used in TableRoutines
Debug.Assert Initializing
Const RoutineName As String = Module_Name & "Add"
On Error GoTo ErrorHandler
Debug.Assert InScope(ModuleList, ModuleName)
If Tbl.Name <> vbNullString Then pAllTables.Add Tbl.Name, Tbl
'@Ignore LineLabelNotUsed
Done:
Exit Sub
ErrorHandler:
RaiseError Err.Number, Err.Source, RoutineName, Err.Description
End Sub ' Add
Public Function Exists( _
ByVal vIndex As Variant, _
ByVal ModuleName As String _
) As Boolean
' Used in TableRoutines
Const RoutineName As String = Module_Name & "Exists"
On Error GoTo ErrorHandler
Debug.Assert InScope(ModuleList, ModuleName)
Exists = pAllTables.Exists(vIndex)
'@Ignore LineLabelNotUsed
Done:
Exit Function
ErrorHandler:
RaiseError Err.Number, Err.Source, RoutineName, Err.Description
End Function ' Exists
Public Sub Remove( _
ByVal vIndex As Variant, _
ByVal ModuleName As String)
' Used in TableRoutines
Const RoutineName As String = Module_Name & "Remove"
On Error GoTo ErrorHandler
Debug.Assert InScope(ModuleList, ModuleName)
If CStr(vIndex) = "*" Then
Set pAllTables = Nothing
Set pAllTables = New Scripting.Dictionary
Else
If Not pAllTables.Exists(vIndex) Then Err.Raise 9
pAllTables.Remove vIndex
End If
'@Ignore LineLabelNotUsed
Done:
Exit Sub
ErrorHandler:
RaiseError Err.Number, Err.Source, RoutineName, Err.Description
End Sub ' Remove