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

Using For..Next instead using Do....While?.

Status
Not open for further replies.

z07924

IS-IT--Management
Feb 18, 2002
122
GB
Can I use the below code instead of using do while loop.

For i = 0 to rs.RecordCount
.............

Next

I know it will work with do while loop
Do While Not rs.EOF
.............
Loop

I want to use for... next. Is it possible to do that?.
If anyonw know the solution, let me know.
Thanks in Advance,
z07924
 
I think it has to be

For i = 0 to (rs.RecordCount - 1)
....
Next

Personally, I wouldn't do it that way. I'd stick with the Do Loop.

-----
The death of dogma is the birth of reason.
 
You could use the "For i = 0" this way
vArray = objRS.GetRows()
objRS.Close
Set objRS = Nothing
For i = 0 To Ubound(vArray, 2)
For x = 0 To Ubound(vArray,1)
Response.Write vArray(x,i) & " - "
Next
Next
 
another opion is :

for each record in rs.records
...............
next
 
this of course assumes that you are returning your recordset as adStatic (or similar), otherwise the recordset.recordcount variable will not be set.....

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top