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

how 2 dim an array with a variable 1

Status
Not open for further replies.

AncientTiger

Programmer
Jul 5, 2001
238
US
Isn't there a way to dim an array with a variable? There used to be in good 'ole basic....

Something like this
==================================

totalrecords = rs.RecordCount

Dim Name(totalrecords) , Address(totalrecords) ......

==================================

I get the error "Constant Expression required"...
 
The only thing that's going to do is set up a Variant...

What I'm needing is a dimmed ARRAY...

Thanks for trying tho :D

AT
 
' Define it then Redim it.
DIM Qarray ' Variant
Redim Qarray(Variablename) ' Put array in Variant

You can also
DIM Qarray() ' Array of Variants
Redim Qarray(Variablename)

There is a difference if passing to VB. Variant containing ann array works. Array of variants doesn't (at least in ASP 1).

Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
GREAT! That worked!! (and it works in newer versions of ASP too ;)

You're a lifesaver John :D
 
Are you sure you want these arrays?

This sure looks like it is leading toward something that disconnected recordsets were intended for!

This was another ASP question. It should have been directed to the ASP Forum where it might have gotten a quicker, more complete answer.
 
Actually, I was using the recordcount as an example. I had ran into the "variable array declaration" problem in VBA, and was stuck. I do both, VBA and ASP, and it works in both...... (go figure, huh? LOL).. Sorry, should have used a VBA example, but my mind runs in multiple modes sometimes...

AT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top