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

Loop with variable name that changes at each pass

Status
Not open for further replies.

dar149

MIS
Mar 5, 2002
117
US
I'm trying to do a loop with a variable where the name changes every time it goes thru the loop count. If the variable is called "pastdue", the first time through the loop I'd have pastdue1, the next time through the loop the variable would change to pastdue2, etc. Each variable contains different data. Is this possible?

Thanks...
 
This sounds like a complex data structure which would probably work better as a dictionary. Can you explain further why you need to do this?
 
Thanks for your input. I think I'll take a different approach.
 
why did you want to add multiple instances of each variable are you sure you don't want another field associated with that one where you store the count.

LikeThisName <- ? Sorry It's Taken =)
 
Hi,

Doesn't this sound like an ARRAY???
Code:
For i = LBound(pastdue, 1) To UBound(pastdue, 1)
  x = pastdue(i) 
Next
???

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Oh, I suppose you could do it that way. [tongue]

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
And if the data are of different types, we may consider a Collection object.
TomThumbKP, for a Dictionary object we musr reference the Scripting runtime.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That is true. However, the dictionary object is faster than the collection object.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top