Question:
I have a number of objects, say shapes, which I have named s1, s2 , s3, s4 , s5.I would like to refer to the shapes fillcolor property witha routine such as FillColor(i,Color).I would like to create the following instruction:
"s"+mid$(str$(i),2).FillColor=Color
I am unable to create the object name in this way.Can it be done? If so, how?
Answer:
Unfortunately, you can’t generate variable names to use in your code. However, if you use a control array, you can programmatically do what you want to. To make a control array, give all five of the controls the same name, and set each of their Index properties to a number in a sequence (1, 2, 3, 4, 5). Then, your code can look something like this:
For i = 1 to 5 Shape(i).FillColor = ColorNext i