how i can create control at runtime?
is this possible?
Regards
Vega.
Try This :
Declaration :
Option explicit
' Contrl variable
Private ctlName As Control
Code :
' This program demonstrates how you can add and delete
' controls on your form dynamically.
' Creates text box and label.
Private Sub cmdCreate_Click()
' Creates label. controls.Add function takes three variables.
' first ("vb.label") accepts what type of control you want created,
' second ("lblLabel1") accepts the name of the control, the last
' one (frmControl) accepts where you want this control to be placed.
Set ctlName = frmControl.Controls.Add("vb.label", "lblLabel1", frmControl)
' Make controls visible. This step is required if you want the control
' to be visible.
ctlName.Visible = True
' Move positions the control requires four arguments
' (left, top, width, height)
ctlName.Move 500, 500, 1500, 250
ctlName.Caption = "Label 1"
Set ctlName = _
frmControl.Controls.Add("vb.textbox", "txtTextBox", frmControl)
ctlName.Visible = True
ctlName.Move 2000, 500, 1500, 250
End Sub
' Quits the program.
Private Sub cmdExit_Click()
End
End Sub
' Removes the controls created in the cmdCreate_Click()
' procedure.
Private Sub cmdRemove_Click()
frmControl.Controls.Remove "txtTextBox"
frmControl.Controls.Remove "lblLabel1"
End Sub
Thank you...
You make my problem solved :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.