Array Problem

1. Junior Member
Join Date
Dec 1969
Posts
24

## Array Problem

I&#039;m creating an array, I got the example from (http://www.4guysfromrolla.com/demos/2dsort.asp)<BR><BR>Dim arrDualArray(4,2)<BR>arrDualArray(0,0) = ""<BR>arrDualArray(0,1) = ""<BR>arrDualArray(0,2) = ""<BR>arrDualArray(1,0) = ""<BR>arrDualArray(1,1) = ""<BR>arrDualArray(1,2) = ""<BR>...<BR>but when I use the following I get the error ... "Cannot use parenthesis when calling a sub" ... Dim arrDualArray(q,2) ... where q is a variable holding a value that may change to dictate the length of the count. How can I get this to work without hard coding the actual number?

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

## You need an integer

Not a variable when declaring an array.<BR><BR>Check out the ReDim property in the VBS docs... dunno if it&#039;ll help you at this point though.<BR><BR>Dim myArray()<BR>ReDim myArray(q) &#039; has to be done this way<BR><BR>Check out what ReDim says about 2D arrays...

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

## This works:

Dim myArray<BR>ReDim myArray(q, 2)

4. Junior Member
Join Date
Dec 1969
Posts
24

## RE: You need an integer

Thanks!<BR><BR>ReDim arrDualArray(q,2) = Dim arrDualArray(4,2) ... which is what I was looking for.<BR><BR>

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

## I thought

You can only change the last dimension?<BR><BR>Oh wait... never mind. That&#039;s only when using Preserve.<BR><BR>Mind is starting come back... fog beginning to lift...

#### Posting Permissions

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