I have a form in my app which allows the user to dynamically create up to 10 command buttons. This is working spendidly, including the coding for the dynamic buttons. The possible choices are listed in a checked Listbox, and they simply select which command button(s) they want at the moment, and they get created. What I need to do now, is to provide them a method of removing the button if they accidentially selected one they are going to be using. To create the buttons, I'm using this
I've listed only one of the routines as an example and changed the caption for clarity sakes. What I can't seem to do, however, is to get the syntax correct for the Controls.Remove Blah Blah. Does anyone know how that works?
Code:
Option Explicit
Private WithEvents btnButtonOne As CommandButton
Private Sub CreateButtonOne()
Set btnButtonOne = Controls.Add("VB.CommandButton", "btnButtonOne")
With btnButtonOne
.Visible = True
.Width = 1000
.Caption = "First Button"
.Top = 1000
.Left = 1000
End With
End Sub