by Bhumika Dave (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 16th November 2000
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Creates A form control such as textbox or listbox without creating an instance or an object
Private Sub Command1_Click()
Dim txtnew As Object
Set txtnew = Form1.Controls.Add("VB.TEXTBOX", "txt1")
txtnew.Visible = True
txtnew.Text = "Hi,I am here"
End Sub
//Similar code for creating a run time ListBox
Private Sub Command3_Click()
Dim lstnew As Object
Set lstnew = Form1.Controls.Add("VB.LISTBOX", "lstname")
lstnew.Left = lstnew.Left + 3000 //Placing of control on the form
lstnew.Visible = True
lstnew.AddItem ("One")
lstnew.AddItem ("Two")
lstnew.AddItem ("Three")
lstnew.AddItem ("Four")
lstnew.AddItem ("Five")
lstnew.AddItem ("Six")
End Sub
Note:Various other Controls can be created by using such VB constant:
Constant Control
_____________________________________
VB.OPTIONBUTTON Creates an Option button
VB.COMBOBOX Creates a Combo box
VB.TEXTBOX Creates a Text box
VB.LISTBOX Creates a List box
VB.CHECKBOX Creates a Check box
VB.LABLE Creates a Lable
No comments have been posted about Creates A form control such as textbox or listbox without creating an instance or an object. Why not be the first to post a comment about Creates A form control such as textbox or listbox without creating an instance or an object.