Um, not exactly..

The ReDim function changes the array size declaration, optionally preserving the existing data. I don't think it allows you to add a dimension - it changes the size of an array. If your array already has 2 or more dimensions, you've reached the Twilight Zone and can only change the size of the last dimension. Arrays of Arrays, as was noted, are much more flexible in terms of resizing, but require a bit more skill and coding to manipulate.

So, if your array was 10 rows of 3 columns, you could add columns (the last dimension) but not rows. If you structured it as 3 columns with 10 rows, you could add rows, but not columns.

Very often, we create the array with the maximum number of cells we thnik we will need, and then use ReDim to resize it down to the actual number of required cells. For example, if I DIM $X[100] and then populate only 37 elements, if I later scan the array, I have to reference each element (using another counter variable) and constantly test for valid data. However, if I know that I only added 37 elements (0-36, remember - it's 0-based), I can resize my array - (assuming the counter var $Ctr post-incremented and is at 37)

ReDim Preserve $X[$Ctr - 1]

Then I could us a For Each loop to enumerate the elements of the array:

For Each $Element in $X ; note the array is $X, not $X[]
$Element ?
Next


Glenn
_________________________
Actually I am a Rocket Scientist! \:D