|
-
January 29th, 2000, 12:05 PM
#1
How to create textbox at run time
I Need to create TextBox at run time ,kindly guide me how can I do that.I need user to input how many names he want to enter if he inputs 10 and OK 10 textbox i need to display if 50 than 50 so kindly guide me.Thanking u in anticipation ,
Vipul
-
January 29th, 2000, 01:02 PM
#2
Re: How to create textbox at run time
just put those 50 textboxes already on the form, but set their visiblility to false, and then when you want those 50 to show set the visibility to true.
-
January 29th, 2000, 01:45 PM
#3
Re: How to create textbox at run time
Use the following.This code adds menus at runtime .U can try to add text boxes.If not then tell me I willsne u code that
option Explicit
Dim gClick as Integer 'Variable to moniotor Clicks
private Sub mnuOpen_Click()
on error GoTo MyError
CommonDialog1.CancelError = true 'Catch the Cancel Button
gClick = gClick + 1 'set gClick to 1
'Show the CommonDialog Open BOx
CommonDialog1.ShowOpen
'Load the first Menu
Load mnuLatestFile(gClick + 1)
'set the visible property to true
mnuLatestFile(gClick + 1).Visible = true
'Change the caption to the file that the user selected
mnuLatestFile(gClick + 1).Caption = CommonDialog1.FileName
Exit Sub
MyError:
Exit Sub
End Sub
-
January 30th, 2000, 06:01 AM
#4
Re: How to create textbox at run time
Here's one way that works with VB 4, 5 and 6 :
Create a form (FORM1) with a textbox (Text1) and a command button (Command1). Set the 'Index' property of Text1 to '0' and paste in the following code :
option Explicit
'
private Sub Command1_Click()
Dim l as Long
Dim sVal as string
'
sVal = InputBox("How many textboxes ?")
'
If sVal = "" then Exit Sub
'
l = CLng(sVal)
'
CreateTextBoxes l
'
End Sub
'
private Sub CreateTextBoxes(byval l as Long)
'
Dim lCount as Long
'
for lCount = 1 to l
'
Load Text1(lCount)
With Text1(lCount)
.Top = Text1(lCount - 1).Top + Text1(lCount - 1).Height + 25
.Width = Text1(lCount - 1).Width
.Left = Text1(lCount - 1).Left
.Visible = true
End With
next
'
End Sub
The program will create the specified number of textboxes underneath the existing one (change the positioning in the CreateTextBoxes routine). When you want to handle events for each textbox, you'll need to remember to check the 'Index' property for each one (if relevant).
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
January 30th, 2000, 08:53 AM
#5
Re: How to create textbox at run time
Why waste system resources loading 50 textboxes, when you can create them at run-time. Using a control array, put a textbox on the form with the index 0, then in your code when you need a new one just use Load textbox_name(new_index). Just make sure you control the index_number or you will end up with bogus boxes.
-
December 20th, 2001, 02:58 AM
#6
Re: a bit of knowledge for a smart trick
;-)
'
'
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
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
|