How to Declare an array of collections?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top