Link to home
Start Free TrialLog in
Avatar of andyw27
andyw27

asked on

changing multiple controls with a single line of code


Hello,

Say I have the following controls on a form:

textbox1
textbox2
textbox3
textbox4

Whats is the most efficient way to set the enable value to false ?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Put all 4 textboxes onto 1 frame, and change the frame's enabled property to false

another option is to create a control array of the 4 textboxes, each having the same name but a different index value.
you can then loop through (assuming you name the control textbox with index values from 0 to 3):

dim l as long
for l = textbox.lbound to textbox.ubound
 textbox(l).enabled = false
next
Avatar of andyw27
andyw27

ASKER


how do you refer to the collective in a control array?

for example text1(0) refers to the first one, is there a way (other than some kind of loop) to influence all members of the control array?
Its not possible in single line and without using loop to change all the control's property.