Here is what I tried to do. I'm sure this will be a learning experience
I have 8 command buttons on a user form that I call "chances" or "strikes".
I wanted to clear out their Captions and wondered if there was a way to deal with them collectively instead of always individually through their userform name.
Creating an array of objects, assigning each button as an object and then working with the objects didn't seem to work.
Run time error 91
Object variable or With block variable not set.
How badly off track am i here? thanks, joe
Public Sub reset_chances()
Dim o As Integer
Dim obj(8) As Object
obj(1) = BoardUserForm1.c_1
obj(2) = BoardUserForm1.c_2
obj(3) = BoardUserForm1.c_3
obj(4) = BoardUserForm1.c_4
obj(5) = BoardUserForm1.c_5
obj(6) = BoardUserForm1.c_6
obj(7) = BoardUserForm1.c_7
obj(8) = BoardUserForm1.c_8
For o = 1 To 8
obj(o).Caption = ""
Next o
End Sub
I have 8 command buttons on a user form that I call "chances" or "strikes".
I wanted to clear out their Captions and wondered if there was a way to deal with them collectively instead of always individually through their userform name.
Creating an array of objects, assigning each button as an object and then working with the objects didn't seem to work.
Run time error 91
Object variable or With block variable not set.
How badly off track am i here? thanks, joe
Public Sub reset_chances()
Dim o As Integer
Dim obj(8) As Object
obj(1) = BoardUserForm1.c_1
obj(2) = BoardUserForm1.c_2
obj(3) = BoardUserForm1.c_3
obj(4) = BoardUserForm1.c_4
obj(5) = BoardUserForm1.c_5
obj(6) = BoardUserForm1.c_6
obj(7) = BoardUserForm1.c_7
obj(8) = BoardUserForm1.c_8
For o = 1 To 8
obj(o).Caption = ""
Next o
End Sub