I'm more or less just curious if this is even possible. There have been many instances where I wished I could just do a for-loop that rotates through controls as well as the relating variables.
Not sure where you are headed with this, but this is as close as I could come up with.
Create a form named "example". Add 5 text boxes named "c1", "c2", "c3", "c4", & "c5".
Paste in the following code in any module:
Code:
Sub Test()
Dim d As Integer
Dim p1 As Integer, p2 As Integer, p3 As Integer, p4 As Integer, p5 As Integer
Dim tmp As Integer
p1 = 100
p2 = 200
p3 = 300
p4 = 400
p5 = 500
For d = 1 To 5
tmp = 0 'clear last value
tmp = Choose(d, p1, p2, p3, p4, p5)
Forms!example.Controls("c" & d) = tmp
Next d
End Sub
Single step through or execute the code. Is this what you are looking for??
As an alternative to the Choose() function, you could instead use "SELECT CASE... END SELECT".