I need sample code to Create an object and display it on a form. Also I need sample code for the object it self(A simple object).
Thank you
Printable View
I need sample code to Create an object and display it on a form. Also I need sample code for the object it self(A simple object).
Thank you
[code]
'add a command button to a form dynamically at run time
'if you want to add properties use the same properties
'as the command button
Option Explicit
Private WithEvents btnObj As CommandButton
Private Sub btnObj_Click()
MsgBox "Hello, this is a dynamically added button."
End Sub
Private Sub Form_Load()
Set btnObj = Controls.Add("VB.CommandButton", "btnObj")
With btnObj
.Visible = True
.Width = 3000
.Caption = "This button was created on the fly!"
.Top = 1000
.Left = 1000
End With
End Sub
[code]
How about if I want to use my own control instead?
Does my control need to have anything special to do this too?