How can i use the createobject() function to create objects like buttons, textboxes etc ? and then to know when an event like text change has occured on the new textbox ?
Printable View
How can i use the createobject() function to create objects like buttons, textboxes etc ? and then to know when an event like text change has occured on the new textbox ?
Code:Option Explicit
' Remarks:
' Dynamically add a new button to the form. The
' item to add, a button in this case, must be a
' member of the VB object as displayed in the
' Object Browser. The second parameter is the
' the new control's name.
'
Private WithEvents btnObj As CommandButton
Private Sub btnObj_Click()
'
' Respond to the new button's Click event.
'
MsgBox "This button was added at run time!"
End Sub
Private Sub cmdAdd_Click()
Set btnObj = Controls.Add("VB.CommandButton", "btnObj")
'
With btnObj
.Visible = True
.Caption = "&Dynamically Added Button"
.Top = 0
.Left = 0
.Width = 2400
.Height = 500
End With
End Sub
Hi,
While you are at it could you please tell me hoe to create a Msword object?
when I use CreateObject("Word.Application") I get runtime error 429
Thanks
umm when i add that to a class like to make the object it dont work it saud the controls.add thing is not a vrable , but when i tested it on a button or somthing it worked , can you help me