MULTIDIMENSIONAL ARRAY HOW!!!!???!!!

# Thread: MULTIDIMENSIONAL ARRAY HOW!!!!???!!!

1. Junior Member
Join Date
Dec 1969
Posts
4

## MULTIDIMENSIONAL ARRAY HOW!!!!???!!!

Hi asp world,<BR><BR>It must be an easy problem but I&#039;m not able to resize a multidimensional array. The code is so simple and I&#039;d like to know why I can resize the array... thank you very much!!!<BR><BR>&#060;%<BR>dim i,x<BR>dim aArray()<BR><BR>for i=0 to 10<BR> for x=0 to 5 <BR> redim preserve aArray(i,x)<BR> aArray(i,x)=i & "//" & x<BR> next<BR>next<BR>%&#062;<BR>&#060;%<BR>for i=0 to 10<BR> for x=0 to 5 <BR> %&#062;&#060;%=aArray(i,x)%&#062;<BR>&#060;%<BR> next<BR> %&#062;----&#060;%<BR>next<BR>%&#062;

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## You can only...

...resize the last dimension.<BR><BR>So:<BR>ReDim myArray(3,1) &#039; &#060;- fine<BR>ReDim Preserve myArray(3, 5) &#039; &#060;- fine<BR>ReDim Preserve myArray(1,5) &#039; &#060;- ERROR.<BR><BR>Craig.

3. Junior Member
Join Date
Dec 1969
Posts
4

## RE: Is it not possible to resize other dimension?

if I want to resize the array&#039;s first dimension how could I do it?

4. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Create a 2nd array of the new size..

.. and then loop through the first array and put all of the data into the 2nd array.<BR><BR>I wrote a script to combine 2 2D arrays. It should give you an idea of how to do this:<BR>http://www.27seconds.com/kb/article_view.asp?id=17

5. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Here's some VB code..

.. that moves the contents from 2 2D array to another.<BR><BR>Private Sub privMove2DArrayContents(ByVal sourceArray As Variant, ByRef targetArray As Variant)<BR>Dim iLowerBound As Integer<BR>Dim iUpperBound As Integer<BR> For iLowerBound = 0 To UBound(sourceArray, 1)<BR> For iUpperBound = 0 To UBound(sourceArray, 2)<BR> targetArray(iLowerBound, iUpperBound) = sourceArray(iLowerBound, iUpperBound)<BR> Next<BR> Next<BR>End Sub

6. Junior Member
Join Date
Dec 1969
Posts
4

## But if I want to REDIM the array?

Is possible to REDIM an array of more than one dimension? In your code the array is already created...but if I have an array that I don&#039;t know the number of elements either in the first dimension nor the second dimension... what could I do?

7. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## It is possible to ReDim an array..

.. of more than one dimension.<BR><BR>You just can&#039;t PRESERVE the contents. Please take a look at the VBScript documentation on ReDim.

8. Junior Member
Join Date
Dec 1969
Posts
4

## RE: It is possible to ReDim an array..

Then.... where could I find that documentation? could you write to me a link?<BR><BR>thank you!!

9. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Look to your left.

Now, look back onto the computer screen and look towards the left. There is a link to the VBScript Reference on almost every page of the aspmessageboard.com.<BR><BR>:)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•