|
-
May 20th, 2003, 12:10 AM
#1
Thread Starter
New Member
Creating Runtime Textbox
[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
Cool Regards,
Suyog 
-
May 20th, 2003, 12:29 AM
#2
New Member
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 :
Code:
Load Text1(1)
Text1(1).Visible = True
Text1(1).Top = 20
Text1(1).Left = 20
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.
So if you want 10 textboxes run the following code :
Code:
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
good luck
Last edited by diziz; May 20th, 2003 at 12:36 AM.
-
May 20th, 2003, 12:54 AM
#3
-= B u g S l a y e r =-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|