How to Declare an array of collections?

  • Thread starter Thread starter Hiram
  • Start date Start date
H

Hiram

Hi,

I've managed to build a widget class and WidgetCollection.
Adding widgets to the collections work like so;

Dim myWidgetCollection As New WidgetCollection()

On a button click I can add widgets to the collection:
Dim aWidget As New Widget()

' Sets the Name field of the new widget.
aWidget.Name = TextBox1.Text
aWidget.value = 99
' Adds the new widget to the collection.
myWidgetCollection.Add(aWidget)


This works,
What I would like to do is have an array of myWidgetCollection.
Each collection houses it's own type of Widgets.
How can this be done where I can add widgets by:

myWidgetCollection(1).Add (aWidget) 'Cheap widgets collection
myWidgetCollection(2).Add (aWidget) 'Good widgets collection
myWidgetCollection(3).Add (aWidget) 'High end widgets.

I've tried to declare the array like so, but this fails:
dim myWidgetCollection (3) As WidgetCollection

Anyone know how to declare this?

Thanks in advance.
Hiram
 
Back
Top