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!

Change Items Sequentially named by formula

Status
Not open for further replies.

ugotaccpaced

Technical User
Jun 3, 2009
26
US
Say I have a game with 999 lights that are named Light001, Light002, Light003 through Light999. At the start of the game I need to turn all 999 lights to on. Is there a way to use For/Next to do this rather than have to individually write code to turn on each light?

ex.
Dim i
For i = 1 to 999
SomeFunction("Light" & Right("000" & i, 3)).State = On
Next
 
Number of ways. One method would be to add all the lights to a dictionary, then you can iterate through the dictionary items (or keys) whenever you like
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top