|
-
Dec 27th, 2001, 11:14 PM
#1
Thread Starter
New Member
add command button
How do i add a command buttun to the form?
Private Sub Command1_Click()
'Code to add the command buttun
End Sub
-
Dec 27th, 2001, 11:17 PM
#2
Member
I believe it goes something like this:
VB Code:
Dim cmdSomeNewButton As New Command1
Load cmdSomeNewButton
cmdSomeNewButton.Caption = "I'm a new button"
(PS, enclose your code in [vbcode][/vbcode] tags to have it automatically color coded. )
-
Dec 27th, 2001, 11:28 PM
#3
Thread Starter
New Member
Originally posted by filburt1
I believe it goes something like this:
VB Code:
Dim
Load cmdSomeNewButton
cmdSomeNewButton.Caption = "I'm a new button"
(PS, enclose your code in [vbcode][/vbcode] tags to have it automatically color coded. )
Didn't work!
User-Defined Type Not defined at cmdSomeNewButton As New Command1
-
Dec 27th, 2001, 11:48 PM
#4
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
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 28th, 2001, 12:12 AM
#5
Thread Starter
New Member
still not working. the error is
Run-time error '50132'
Not a legal object name: "
-
Dec 28th, 2001, 12:19 AM
#6
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.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 28th, 2001, 12:26 AM
#7
Thread Starter
New Member
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.
Yes it worked.
Thank You All
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|