[SIZE=1][FONT=times new roman][COLOR=blue]
I would Like to create text box at run time on VB Form ?
If any one knows then please reply me .
Thanks in Advance
Warm Regards
Suyog
Printable View
[SIZE=1][FONT=times new roman][COLOR=blue]
I would Like to create text box at run time on VB Form ?
If any one knows then please reply me .
Thanks in Advance
Warm Regards
Suyog
An easy way is to create a textbox first and hide it (.visible = false) and then show it when you want....but I guess that is not what you are after.
Another way is to first create a textbox, set the index property to "0" and let the name be the default "text1". Then run the following code under a command button for example :
This will create an additional textbox for you. When creating an object like this it is by default hidden, so we need to set the visible propery to true and also move it a little bit so it won't be exactly on top of the other one.Code:Load Text1(1)
Text1(1).Visible = True
Text1(1).Top = 20
Text1(1).Left = 20
So if you want 10 textboxes run the following code :
good luckCode:Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 10
Load Text1(i)
Text1(i).Visible = True
Text1(i).Top = i * 200
Text1(i).Left = i * 200
Next i
End Sub
an alternative is to create it from scratch, without making any controls up front.
VB Code:
Private Sub Command1_Click() Dim ctlTxtBox As Control Set ctlTxtBox = Controls.Add("VB.TextBox", "ctlTxtBox1", Form1) ctlTxtBox.Height = 2000 ctlTxtBox.Width = 2000 ctlTxtBox.Visible = True End Sub