View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Class Instance Identifier

Art,

You can create a class module, say Class1, with the properties
you need, including a field called Key. Then, add the instances
of the class to a Collection object, using the Key property of
the class as the key to the collection. E.g,

Dim Coll As Collection

Sub AAA()
Dim C1 As Class1
If Coll Is Nothing Then
Set Coll = New Collection
End If
Do Until somthing
Set C1 = New Class1
C1.Field1 = "whatever"
C1.Key = "KeyName"
Coll.Add C1, C1.Key
Loop
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Art" wrote in message
...
Hi,

I need a collection for about 50 things. I'm assuming that a

sensible way to do this is to create a class where I can have a
bunch of properties for each of the instances, and instantiate it
about 50 times.

I'd like to create each instance with a "key" so that I can

refer to specific instances as necessary.

It may be that there's a way to create a data structure instead

of a class or to create a collection.

Can anyone suggest anything?

Art