Private Key
Private Item
Private Sub Class_Initialize()
Dim t(), t2(): ReDim Preserve t(0): ReDim Preserve t2(0): Key = t: Item = t2
End Sub
Public Function Add(k As String, Optional i As Variant = "", Optional ByVal Overwrite_Item As Boolean = True)
x = Application.IfError(Application.Match(k, Key, 0), 0)
If x = 0 Then
a = UBound(Key) + 1: ReDim Preserve Key(1 To a): ReDim Preserve Item(1 To a): Key(a) = k: Item(a) = i
Else
If Overwrite_Item Then Item(x) = i
End If
End Function
Public Function keys(Optional k As String = "")
If k = "" Then keys = Key Else For i = 1 To UBound(Key): keys = IIf(Key(i) = k, Item(i), ""): Next
End Function
Public Function items(Optional it As String = "")
If it = "" Then
items = Item
Else: For i = 1 To UBound(Item)
If Item(i) = it Then items = Key(i)
Next
End If
End Function
Function Sort()
Dim temp, temp2, i&, a&
For i = 1 To UBound(Key) - 1
For a = i + 1 To UBound(Key)
If Key(i) > Key(a) Then
temp = Key(i): temp2 = Item(i)
Key(i) = Key(a): Key(a) = temp
Item(i) = Item(a): Item(a) = temp2
End If
Next
Next
End Function