Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redim a multi dimensional array

Status
Not open for further replies.

Geates

Programmer
Aug 25, 2009
1,566
0
0
US
I can't figure out how to dim and redim a multi-dimensional array while maintaining content. I have no issues with single dimension array. I've tried:

i=2
j=3

dim arr()
redim preserve arr(i, j)
error: Subscript out of range

dim arr(0,0)
redim preserve arr(i, j)
error: The array is fixed or temporarily locked

dim arr(,)
redim preserve arr(i, j)
error: Are you an idiot?

Any ideas (not pertaining to the last error)?

-Geates
 


hi,
HELP said:
Preserve Optional. Keyword used to preserve the data in an existing array when you change the size of the last dimension.
i=2
j=3

dim arr(2,0)

redim preserve arr(i, j)


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi Geates,

You can only redim the last dimension of an array. That means you need to structure the array so that the dimmension that might need to be redimmed is the last one.


Cheers
[MS MVP - Word]
 
That's counter intuitive. Oh well, got it working. Thanx to both of you

-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top