E
ExcelMonkey
Why am I getting an Run time error 424 when trying to change the visible
properties in a control which is loaded into a collection. The collection is
dim'd as a Public variable. I am trying to change this property within a
click event of a button on the form
Public cntrlclctn1 As Collection
Private Sub CommandButton1_Click()
Dim x As Integer
For x = 1 To cntrlclctn1.Count
cntrlclctn1(x).Visible = True
Next
End Sub
Sub thing()
Dim lbl As Control
Dim txtbx As Control
'Create controls
Set lbl = UserForm1.Controls.Add("Forms.Label.1")
lbl.Caption = "Label Text"
lbl.Visible = False
Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1")
txtbx.Text = "Text Box Text"
txtbx.Visible = False
'Add controls to collection
Set cntrlclctn1 = New Collection
cntrlclctn1.Add (lbl)
cntrlclctn1.Add (txtbx)
UserForm1.Show
End Sub
properties in a control which is loaded into a collection. The collection is
dim'd as a Public variable. I am trying to change this property within a
click event of a button on the form
Public cntrlclctn1 As Collection
Private Sub CommandButton1_Click()
Dim x As Integer
For x = 1 To cntrlclctn1.Count
cntrlclctn1(x).Visible = True
Next
End Sub
Sub thing()
Dim lbl As Control
Dim txtbx As Control
'Create controls
Set lbl = UserForm1.Controls.Add("Forms.Label.1")
lbl.Caption = "Label Text"
lbl.Visible = False
Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1")
txtbx.Text = "Text Box Text"
txtbx.Visible = False
'Add controls to collection
Set cntrlclctn1 = New Collection
cntrlclctn1.Add (lbl)
cntrlclctn1.Add (txtbx)
UserForm1.Show
End Sub