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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays and VBScript... 3

Status
Not open for further replies.

mmaz

Programmer
Nov 22, 2000
347
Hi,

Is it possible to build a multi-dimensional array in VBScript? If so, what is the syntax?

Thanks in advance!

Marie :)
 
dim myArray(3, 5)

You now have a 3x5 array.

hope it helps!:)
Paul Prewett
 
Thanks a lot!! I appreciate the help!
 
Paul, it looks like this array cannot be dynamic. Am I right? If I put a variable of type integer inside the brackets:

dim myArray(3,intCount)

I get the error:

Microsoft VBScript compilation error '800a0402'
Expected integer constant
 
Oops, I just read about Redim...Forget about my last question.
 
mmaz -
here's a side note.
in VBScript 5.0, you can use execute.

for example:
execute "dim someArray(" &dimension1& "," &dimension2& ")"

if you do it this way, then you can create perfectly sized arrays every time, so you don't even need to worry about the redim statement. I don't know if there's a performance increase or not regarding execute, but it's worth a thought.

In case you were wondering, you can 'execute' any valid VB code within the "". So far the only useful one I've thought of is the perfect array.

hope this helps.
leo
 
You can also
Code:
redim
the innermost dimension of a multidimensonal array, e.g.

Code:
dim myArray(3,4)

redim myArray(3, intCount)

hope this helps. Yours,

Rob.
 
Hi,
Does VBScript follow (Row,Column) format or (Column,Row) format ?


Thank you,
RR.
__________________________________
The best is yet to come.
 
Its (Row, Col).

ie.

For i = 1 to 5
For j = 1 to 5
array(i, j) - first run would be (1, 1), (1, 2), etc
Next
Next

Brett Birkett B.Comp
Systems Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top