User defined type problem
I'm afraid I didn't say exactly what i meant. To clear up all
confusion, the code is below.
The problem occurs when I want to store many of these Types in a
Collection or Dictionary. The compiler complains about various things,
depending on where and what scope the Type is defined with.
Basically, I want to store a LOT of MyType records in a dictionary so
that I can immediately summon on by Key. If I cannot do this directly,
I guess an alternative would be to store them in an array, and store the
keys and array indices in a dictionary. However, this is a little less
intuitive and natural, and a lot more annoying. Any help would be
appreciated.
################################################
Module code
################################################
Type MyType
Item1 As String * 6
Item2 As Double
End Type
################################################
Class Module code
################################################
Private colItems As Collection
Private Sub Class_Initialize()
Set colItems = New Collection
End Sub
Public Sub Add(ByRef WhichItem As MyType)
colItems.Add WhichItem
End Sub
Public Function Item(ByVal Index As Long) As MyType
Item = colItems.Item(Index)
End Function
|