Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 18 combo boxes labelled YB1 to YB18. These boxes can either be set to "Yes" or "No" on the input form.
I want to be able to firstly read the number at the end of the label. Then use that number as the first part of a For Loop.
Then I want to be able to use a for loop to set all subsequent combo boxes' value to Yes
once a combo box has been set by the user to Yes.
ie If the user sets YB6 to Yes then the code sets Combo boxes YB7 to YB 18 to Yes.
What I do not know is firstly how to read the number of the box. Secondly to create the combobox label using a For Loop variable.
Posted
Updated 16-Dec-15 7:12am
v2

1 solution

You can use Controls.Find() in a loop. It takes a string name for the control.

For example, if i is your loop variable:
VB
ComboBox cbx = Controls.Find("YB" + i, true)
IF cbx IS NOT NOTHING THEN
 ...
END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900