I have a problem with VB.Net:
Having a section of Text Boxes that I need to enable and disable by command buttons.
The names are: txtBx1, txtBx2… and so on. Attempting to loop through those with the assignments to en- or disable failed.
VB.Net does not recognize the names when adding the numeric name parts.

Dim i as integer
For i = 1 to 10
“txtBx”&i.enabled = False
Next i

Returns nothing but errors.

I tried multiple ways to combine loop integer with the string value and all failed.
Does someone have a clue how to get this to work?

I appreciate any advice.

Recommended Answers

All 3 Replies

VB.NET stores controls, like text boxes, to a control collection. See this DaniWeb's thread, how to loop through the control collection, recognize text boxes and finally, how to use control's properties.

VB.NET stores controls, like text boxes, to a control collection. See this DaniWeb's thread, how to loop through the control collection, recognize text boxes and finally, how to use control's properties.

Thank you ! (This explains why I could not squeeze anything out of my books, I was looking in the wrong sections!)
A big thanks again for your help!

Hi! Nice to hear that you got answer to your problem. Could you please mark the thread as solved. Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.