T
Teodomiro
I just finished a project, and everything works fine, but there is some
pretty clunky-looking code making it work. Here's part of my Form
Reset code, which illustrates what I'm talking about:
-----
UserForm1.CommandButton1.BackColor = vbButtonFace
UserForm1.CommandButton2.BackColor = vbButtonFace
UserForm1.CommandButton3.BackColor = vbButtonFace
UserForm1.CommandButton4.BackColor = vbButtonFace
UserForm1.CommandButton5.BackColor = vbButtonFace
UserForm1.CommandButton6.BackColor = vbButtonFace
UserForm1.CommandButton7.BackColor = vbButtonFace
UserForm1.CommandButton8.BackColor = vbButtonFace
UserForm1.CommandButton9.BackColor = vbButtonFace
UserForm1.CommandButton10.BackColor = vbButtonFace
UserForm1.CommandButton11.BackColor = vbButtonFace
UserForm1.CommandButton12.BackColor = vbButtonFace
UserForm1.CommandButton13.BackColor = vbButtonFace
UserForm1.CommandButton14.BackColor = vbButtonFace
UserForm1.CommandButton15.BackColor = vbButtonFace
UserForm1.CommandButton16.BackColor = vbButtonFace
UserForm1.CommandButton17.BackColor = vbButtonFace
UserForm1.CommandButton18.BackColor = vbButtonFace
UserForm1.CommandButton19.BackColor = vbButtonFace
UserForm1.CommandButton20.BackColor = vbButtonFace
-----
I had to do this sort of thing with several different controls. It
seems to me that there ought to be a more elegant way of doing this
sort of thing. Is it possible to reference controls with a variable?
Is there a better way of doing this?
pretty clunky-looking code making it work. Here's part of my Form
Reset code, which illustrates what I'm talking about:
-----
UserForm1.CommandButton1.BackColor = vbButtonFace
UserForm1.CommandButton2.BackColor = vbButtonFace
UserForm1.CommandButton3.BackColor = vbButtonFace
UserForm1.CommandButton4.BackColor = vbButtonFace
UserForm1.CommandButton5.BackColor = vbButtonFace
UserForm1.CommandButton6.BackColor = vbButtonFace
UserForm1.CommandButton7.BackColor = vbButtonFace
UserForm1.CommandButton8.BackColor = vbButtonFace
UserForm1.CommandButton9.BackColor = vbButtonFace
UserForm1.CommandButton10.BackColor = vbButtonFace
UserForm1.CommandButton11.BackColor = vbButtonFace
UserForm1.CommandButton12.BackColor = vbButtonFace
UserForm1.CommandButton13.BackColor = vbButtonFace
UserForm1.CommandButton14.BackColor = vbButtonFace
UserForm1.CommandButton15.BackColor = vbButtonFace
UserForm1.CommandButton16.BackColor = vbButtonFace
UserForm1.CommandButton17.BackColor = vbButtonFace
UserForm1.CommandButton18.BackColor = vbButtonFace
UserForm1.CommandButton19.BackColor = vbButtonFace
UserForm1.CommandButton20.BackColor = vbButtonFace
-----
I had to do this sort of thing with several different controls. It
seems to me that there ought to be a more elegant way of doing this
sort of thing. Is it possible to reference controls with a variable?
Is there a better way of doing this?