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!

variables & loops

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I am trying to create a variable in a loop eg

While done = "FALSE"
count = count + 1
dim levelcount
levelcount = info from dbase

Wend

if this loops through 3 times, I want to be able to have 3 variables at the end: level1, level2, level3.

 
Well, if the above loop executes more than once, you will get a runtime error for trying to dim the same variable name twice. My suggestion would be to create an array and fill an element on each iteration of the loop:
Code:
dim levelCounter(numOfElements)
dim count
count = 1

While not done
    levelcount(count) = info from dbase 
    count = count + 1
Wend

Performance will always improve if you use boolean evaluation of a boolean variable (not). I also have a question of how
Code:
 done
is going to change... but I'll leave that up to you.

hope it helps!:)
Paul Prewett
 
Thanks just what I wanted

cheers for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top