Closed Thread Icon

Topic awaiting preservation: ASP and Arrays (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12820" title="Pages that link to Topic awaiting preservation: ASP and Arrays (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: ASP and Arrays <span class="small">(Page 1 of 1)</span>\

 
Blaise
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 07-17-2003 06:23

Hi there, I'm having troublw using arrays,

I want to create a dynamic array based on the amount of records I have in a table, so I wrote a piece of code like this...

code:
SQL = "SELECT * FROM Table"
SET Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open SQL, conn

I = 0

WHILE NOT Rs.EOF
I = I + 1
Rs.MoveNext
WEND
IF NOT Rs.BOF THEN Rs.MoveFirst

Dim fDayq(I)



Here you can see that I want fDayq to be my dynamic array and to have 'I' possibillities.

This doesn't work and I get an error 'Expected integer constant' where 'I' is so I guess I'm not doing this the right way, is there a way to create a dynamic array in ASP, what are the constraints?

TIA

Blaise.

Blaise
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 07-17-2003 06:37

Well gues what I managed to find the answer in the end (finally!)

My code now looks like this...

code:
Dim fday()

SQL = "SELECT * FROM Table"
SET Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open SQL, conn

I = 0

WHILE NOT Rs.EOF
I = I + 1
Rs.MoveNext
WEND
IF NOT Rs.BOF THEN Rs.MoveFirst

ReDim fDayq(I)



So to use a dynamic array you must first 'Dim' your variable with enpty parenthesis '()' then use the 'ReDim' term to assign how many items are in the array, hence 'ReDim fDayq(I)'

Well I hope this helps someone else!

Cya

Blaise.

« BackwardsOnwards »

Show Forum Drop Down Menu