Nearly ...
You are creating an ArrayList of ArrayLists.
In a module, declare:
Public MyArrayLists As New ArrayList
It is important that it is done with the New keyword, otherwise your
ArrayList of ArrayLists will not be instantiated.
Because it is an ArrayList and NOT an array, ReDim is inappropriate.
At the local level you create create an ArrayList:
Dim _arraylist As New ArrayList
and then you add elements to it:
_arraylist.Add( Value)
and finally you add the local ArrayList to the 'global' ArrayList
MyArrayLists.Ad d(_arraylist)
Now, I hear you ask, how do I access the elements of MyArrayList and how do
I know which one is which?
The use of ArrayLists, as demonstrated, is only one way of doing it. There
are other ways, some of which are better than others.
For example, use of a Generic Dictionary object would allow you to implement
a solution where each element of the Dictionary is a name/value pair with
the value part being a single ArrayList. The elements of the Dictionary
would be accesible by the name you assigned at the time ou added the
element.
It's a matter of you researching these other techniques and deciding which
one is best for your solution.
"vbnewbie" <bi*****@gmail. comwrote in message
news:11******** ************@s3 4g2000cwa.googl egroups.com...
>
Stephany Young wrote:
>Yes. A Module.
Public MyArrayLists As New ArrayList
MyArrayLists will be available from anywhere in your project.
Thanks Stephany
Just to recap:
If I follow what HKSHK wrote before, I am creating an array of
arraylists.
I declare my array in a module: Public MyArrayLists() As ArrayList
I Redim my array at local level: ReDim MyArrayLists (aNumber)
I create my arraylists at local level: MyArrayLists(0) = New ArrayList,
etc
I add to my arraylists at local level: MyArrayLists(0) .Add(Value)
Is that correct?
Thanks all for your patience...