Step through text boxes (objects) with code

Step through text boxes (objects) with code

Anonymous
Not applicable
337 Views
2 Replies
Message 1 of 3

Step through text boxes (objects) with code

Anonymous
Not applicable
VBA noobie question . . .

Is it possible to step through text boxes (or any object) with code

Here's a rough sample trying to manipulate TextBox1 and TextBox2:

sub tboxmod()

Dim n As Integer
Dim Tname As String
For n = 1 To 2
Tname = "TextBox" & n
Dim TBox As TextBox

Set TBox = Tname
TBox.Text = "n"

Next n

End Sub

Thanks in advance
0 Likes
338 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
I don't reallt understand what you are doing. If you have a dialogue which a TextBox property on it, you should handle the TextBox_Change event handler to keep track of changes.

Also, you might want to look at the .Value property as opposed to the .Text property.

Hope this helps.

Andrew
0 Likes
Message 3 of 3

Anonymous
Not applicable
Check out the last few posts in the thread "Object Variable Not Set Error" I had tacked it on as an extra question, and I think the answers might help.
0 Likes