E
ExcelMonkey
I have a for that I want to add various controls to. I want to dilineate the
controls by adding them to two separate collections. Once added, I will have
two separate buttons which I will click. One button's click event will show
the controls in the first collection and the second button's click event will
show the controls in the second collection. I am getting error 424 in my
button click events in my For..Next stmts. What am I doing wrong?
'****************************************
Public CntrlColctn1 As Collection
Public CntrlColctn2 As Collection
Public lbl As Label
Public cmbx As ComboBox
Public btn As Button
Public chkbx As CheckBox
Public lstbx As ListBox
Public frm As Frame
'**********************************
'Regular Module
Public Sub Thing()
UserForm1.Show
End Sub
'**********************************
Private Sub UserForm_Load()
Set lbl = Me.Add(Label)
Set cmbx = Me.Add(ComboBox)
Set btn = Me.Add(Button)
Set chkbx = Me.Add(CheckBox)
Set lstbx = Me.Add(ListBox)
Set frm = Me.Add(Frame)
CntrlColctn1.Add (lbl)
CntrlColctn1.Add (cmbx)
CntrlColctn1.Add (btn)
CntrlColctn2.Add (chkbx)
CntrlColctn2.Add (lstbx)
CntrlColctn2.Add (frm)
End Sub
'************************************
Private Sub CommandButton1_Click()
Dim x As Control
For Each x In CntrlColctn2
x.Hide
Next
For Each x In CntrlColctn1
x.Show
Next
End Sub
'********************************
Private Sub CommandButton2_Click()
Dim x As Control
For Each x In CntrlColctn1
x.Hide
Next
For Each x In CntrlColctn2
x.Show
Next
End Sub
Thanks
EM
controls by adding them to two separate collections. Once added, I will have
two separate buttons which I will click. One button's click event will show
the controls in the first collection and the second button's click event will
show the controls in the second collection. I am getting error 424 in my
button click events in my For..Next stmts. What am I doing wrong?
'****************************************
Public CntrlColctn1 As Collection
Public CntrlColctn2 As Collection
Public lbl As Label
Public cmbx As ComboBox
Public btn As Button
Public chkbx As CheckBox
Public lstbx As ListBox
Public frm As Frame
'**********************************
'Regular Module
Public Sub Thing()
UserForm1.Show
End Sub
'**********************************
Private Sub UserForm_Load()
Set lbl = Me.Add(Label)
Set cmbx = Me.Add(ComboBox)
Set btn = Me.Add(Button)
Set chkbx = Me.Add(CheckBox)
Set lstbx = Me.Add(ListBox)
Set frm = Me.Add(Frame)
CntrlColctn1.Add (lbl)
CntrlColctn1.Add (cmbx)
CntrlColctn1.Add (btn)
CntrlColctn2.Add (chkbx)
CntrlColctn2.Add (lstbx)
CntrlColctn2.Add (frm)
End Sub
'************************************
Private Sub CommandButton1_Click()
Dim x As Control
For Each x In CntrlColctn2
x.Hide
Next
For Each x In CntrlColctn1
x.Show
Next
End Sub
'********************************
Private Sub CommandButton2_Click()
Dim x As Control
For Each x In CntrlColctn1
x.Hide
Next
For Each x In CntrlColctn2
x.Show
Next
End Sub
Thanks
EM