trouble with multi-dimensional arrays

# Thread: trouble with multi-dimensional arrays

1. Senior Member
Join Date
Dec 1969
Posts
115

## trouble with multi-dimensional arrays

according to:<BR>http://www.aspfaqs.com/ASPScripts/PrintFAQ.asp?FAQID=146<BR>and<BR>http://www.aspfaqs.com/ASPScripts/PrintFAQ.asp?FAQID=63<BR><BR>I should be able to do the following:<BR>&#039;multiarray=array(5,2)<BR>&#039 ;multiarray=array(2,5)<BR>&#039;multiarray=array(2 ,2)<BR>&#039;Dim multiarray()<BR>multiarray=array()<BR>&#039;These cause a subscript error<BR>multiarray=split("one,two,three,four,five ", ",")<BR>redim preserve multiarray(5,5)<BR>&#039;redim preserve multiarray(5,2)<BR>&#039;redim preserve multiarray(2,5)<BR>&#039;redim preserve multiarray(2,2)<BR>multiarray(2)=split("five,four, three,two,one", ",")<BR><BR>The commented lines show the various combinations of things I&#039;ve tried. Each time, I get a "Subscript out of Range" error on the redim line.<BR><BR>What stupid thing am I forgetting?<BR><BR>MYK

2. Senior Member
Join Date
Dec 1969
Posts
11,334

## RE: trouble with multi-dimensional arrays

Because Split() returns a variant. Which means to you do NOT dim the variable with any dimensions.<BR><BR>Dim myArray &#039;no dimensions<BR><BR>myArray = Split(...)<BR><BR>To make it two d, you may have to do a double split, or an array of arrays.

3. Senior Member
Join Date
Dec 1969
Posts
115

## RE: trouble with multi-dimensional arrays

let me be more specific:<BR><BR>multiarray=array()<BR>&#039;or <BR>&#039;Dim multiarray()<BR>redim preserve multiarray(5,5)<BR><BR>causes a Subscript out of range error.<BR><BR>Why?

4. Senior Member
Join Date
Dec 1969
Posts
11,334

## RE: trouble with multi-dimensional arrays

array() also returns a variant.<BR><BR>You want<BR><BR>Dim multiArray(5,5)<BR><BR>But ya can&#039;t use that with split(). Preserve also doesn&#039;t work too well with multi dimension arrays (you can only use it to preserve the last dimension)

5. Senior Member
Join Date
Dec 1969
Posts
115

## thanx!! RE: trouble with multi-dimensional arrays

Thanx, Desert Ghost...

#### Posting Permissions

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