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

multidimensional array

Status
Not open for further replies.

Marchello2004

Technical User
Sep 29, 2005
12
GB
Anyone know how to define a multidimensional array in VBScript without knowing constant dimensions (ie, using variables to define the dimensions)?

Help greatly appreciated.
 
[tt]dim a()
p=3
q=2
r=4
'all dimensions redim only once except the last dimension
redim a(p,q,r)
wscript.echo ubound(a,1) & vbcrlf & ubound(a,2) & vbcrlf & ubound(a,3)

r=10
redim preserve a(p,q,r)
wscript.echo ubound(a,1) & vbcrlf & ubound(a,2) & vbcrlf & ubound(a,3)

on error resume next
p=5
redim preserve a(p,q,r)
if err.number<>0 then
wscript.echo hex(err.number) & vbcrlf & err.description
err.clear
end if
on error goto 0
wscript.echo ubound(a,1) & vbcrlf & ubound(a,2) & vbcrlf & ubound(a,3)[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top