Thanks, Aidy, for your suggestion. Why doesn't
>
arrColors(0).Add("Red"),
arrColors(1).Add("Blue")
etc. add anything to the array?
Basically an ArrayList is not an array, it is just a collection of objects.
With an array, if I create a 5 length array then I get a structure that can
hold 5 elements of my given type. So I can then do;
arr[0] = "Red"
arr[1] = "Blue"
etc.
When you create an ArrayList, you merely get an object that is an empty
collection, it has no objects in it so you can't do
arr[0] =
as there is nothing at position 0. For there to be something at position 0
you have to add it;
arr.Add("Red") -- this is the first thing added so will have position 0
You're just getting confused between arrays and the ArrayList object,
they're not the same. This syntax;
arrColors(0).Add("Red")
is the same as this
Dim o as Object
o = arrColours(0)
o.Add("Red")
What you're doing is getting the object at position 0 then calling that
object's Add method. As well as the problem above of there being no objects
in the array, if there *was* an object such as a string "Red" then you're
calling the Add method of that object which can give you errors if the
object doesn't support it. You are *not* calling the Add method of the
ArrayList, you are calling the Add method of the object at that position.
Also is it possible to ReDim & Preserve with ArrayList?
Again not really as they are just collections. The ArrayList will grow and
shrink in size as you add/remove elements.