I have 18 text boxes named 'txtmybox' with indexes set as 0 to 17.

To change the back color I currently use a for..next loop ie:

for x = 0 to 17
txtmybox(x).backcolor=red
next x


The question is - is there a quicker way to perform this task, ie change all boxes in one go?


thanks

Recommended Answers

All 3 Replies

that is the simplest way

As ChrisPadgham said..that is a simplest way.
This following is other way (But Still needed to use Looping):

For Each controlx In Form1.Controls
    If TypeOf controlx Is TextBox Then controlx.BackColor = vbRed
Next controlx

Thanks for the replies

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.