You can't do any tricks with variable names. In the compiled code -- which
is what actually runs -- there are no variable names at all; only pointers.
Two workarounds that might suit (depending on what else is going on in your
code) --
1) Use an array of arrays:
Dim pData(1 to 4) as variant
Dim aryA() as string
Dim aryB() as string
pData(1) = aryA
pData(2) = aryB
It's maybe a little obfuscated, but you can refer to aryA(3) using
pData(1)(3)
2) Use a collection:
Dim pCollection as collection
Dim aryA() as string
Dim aryB() as string
set pCollection = new collection
pCollection.Add Item:=aryA, Key:="Array_A"
Thanks, Jezebel. Thinking a bit more, I wonder if it's possible and, if so,
maybe easier to use a two-dimensional array and use a variable to decide
where I'm writing. For instance, if I have six series of data, can I write
to MyAry(x, y), where "x" is assigned to 1-6 according to which series I
assign my data to?
Also, if I use ReDim Preserve with this, I know I can only resize "y". Is
"y" then the total number of elements across the whole complete array, or
just that section of the array? Or do I ReDim to the highest number of
elements in any single section? If in MyAry(1,y) y=4 and in MyAry(2,y) y=6,
if I wanted to add another item to MyAry(1,y+1) would I have to ReDim to 5,
or to 11, or not have to ReDim at all because MyAry(2,y) has 6 items, more
than the 5 the first section will have? (Did that make sense??)
Ed
> You can't do any tricks with variable names. In the compiled code -- which
> is what actually runs -- there are no variable names at all; only
[quoted text clipped - 39 lines]
>> Any help?
>> Ed
Jezebel - 04 May 2006 05:14 GMT
Yes you can use a two-dimensional (or indeed any dimensional) array; but the
dimensions are constant (think of the array as representing a rectangle -
or cube or whatever - of cells). So you'd have to set it up for the second
dimension to accommodate the largest set of values you might need.
> Thanks, Jezebel. Thinking a bit more, I wonder if it's possible and, if
> so, maybe easier to use a two-dimensional array and use a variable to
[quoted text clipped - 56 lines]
>>> Any help?
>>> Ed