Type mismatch using "for each" with controls on a form.
Posted on 2003-11-07
This must seem very basic. I haven't used for each much before, but I seem to remember seeing similar examples to this somewhere...
In the example below, I have 4 textboxes on a form and a command button. I want to change the background of all the textboxes. When I run the program, the textboxes do change colour, but I get "run time error 13 - type mismatch.". What am I doing wrong?
Private Sub Command1_Click()
Dim t As TextBox
For Each t In Me
t.BackColor = RGB(100, 0, 0)