Variable in a 2D array def.
Posted on 2001-06-10
I trying to set up a 2D array where the 1st dim should be equal to the number of database records returned and the 2nd dim is a constant...the number of fields.
My reasoning is that I should be able to express the 1st dim as a variable and within the iteration have:
ReDim Preserve myarray(counter, 5)
Here's the code I'm using:
for aIndex = 1 to rec_count
redim preserve q(aIndex,5)
Microsoft VBScript compilation error '800a0402'
Expected integer constant
/quiz.asp, line 78
If I hardcode the first dim to:
dim q(5,5) '5 happens to be known to be max possible
the error falls to the redim as:
Microsoft VBScript runtime error '800a0009'
Subscript out of range
/quiz.asp, line 87
I can get my page to work if I don't try to re-dim and I hardcode the 1st dim to my largest known recordset. But I'd like to understand the process. I've seen variables used in 2D arrays elsewhere.