How do i add a command buttun to the form?
Private Sub Command1_Click()
'Code to add the command buttun
End Sub
Printable View
How do i add a command buttun to the form?
Private Sub Command1_Click()
'Code to add the command buttun
End Sub
I believe it goes something like this:
(PS, enclose your code in [vbcode][/vbcode] tags to have it automatically color coded. :))VB Code:
Dim cmdSomeNewButton As New Command1 Load cmdSomeNewButton cmdSomeNewButton.Caption = "I'm a new button"
Didn't work!Quote:
Originally posted by filburt1
I believe it goes something like this:
(PS, enclose your code in [vbcode][/vbcode] tags to have it automatically color coded. :))VB Code:
Dim Load cmdSomeNewButton cmdSomeNewButton.Caption = "I'm a new button"
User-Defined Type Not defined at cmdSomeNewButton As New Command1
try this...
VB Code:
Dim WithEvents cmdNewButton As CommandButton Private Sub Command1_Click() Set cmdNewButton = Me.Controls.Add("VB.CommandButton",cmd) With cmdNewButton .Visible = True .Top = 10 .Left = 10 End With End Sub Private Sub cmdNewButton_Click() MsgBox "I'm a new button" End Sub
still not working. the error is
Run-time error '50132'
Not a legal object name: "
Set cmdNewButton = Me.Controls.Add("VB.CommandButton",cmd)
just for sh*ts and giggles, try changing the above line to :
Set cmdNewButton = Me.Controls.Add("VB.CommandButton","cmd")
and see if it works.
:)
Yes it worked.VB Code:
Set cmdNewButton = Me.Controls.Add("VB.CommandButton",cmd) just for sh*ts and giggles, try changing the above line to : Set cmdNewButton = Me.Controls.Add("VB.CommandButton","cmd") and see if it works.
Thank You All