Glory
Well-known Member
- Joined
- Mar 16, 2011
- Messages
- 640
I’ve built a userform. The userform contains “commandbutton1”, created at design time.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> </o>
A checkbox appears at runtime. The idea is that the checkbox is deleted when the user presses the command button.
<o> </o>
The code doesn’t work. Any ideas why?
<o> </o>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> </o>
A checkbox appears at runtime. The idea is that the checkbox is deleted when the user presses the command button.
<o> </o>
The code doesn’t work. Any ideas why?
<o> </o>
Code:
Private Sub Userform_initialize()<o:p></o:p>
<o:p> </o:p>
Set g = Me.Controls.Add("Forms.Checkbox.1")<o:p></o:p>
<o:p> </o:p>
g.Name = "CheckBox1"<o:p></o:p>
g.Caption = "Hello"<o:p></o:p>
g.Height = 22<o:p></o:p>
g.Left = 6<o:p></o:p>
g.Top = 12<o:p></o:p>
g.Width = 72<o:p></o:p>
g.Visible = True<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Sub CommandButton1_Click()<o:p></o:p>
<o:p> </o:p>
UserForm1.Controls("CheckBox1").Remove<o:p></o:p>
<o:p> </o:p>
End Sub