Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically add a textbox to a user form based on user requireme
I was wondering if it is possible to automatically add a text box to a user
form based on user requirements? I'm trying to make a wizard, and the way i want it to work is: 1. A userform will appear asking how many sources of revenue the user would like to enter. 2. On the next userform i want the appropriate number of text boxes to appear so that the user can enter all of their data. For example. Say a user enters that they would want to enter 3 sources of revenue. On the next screen i want a user form to appear with three textboxes so that they can enter all of their data. Is there a way to do this? thanks in advance for your help! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically add a textbox to a user form based on user requireme
Hi Brite,
populate the second userform with as many textboxes as a value from the first userform returns: Private Sub UserForm_Click() Dim l As Long UserForm1.Hide For l = 1 To Me.TextBox1.Value Set obj = UserForm2.Controls.Add("Forms.TextBox.1") If l = 1 Then obj.Top = 20 Else obj.Top = l * 20 End If Next UserForm2.Show End Sub Adjusting the size of the userform2 is another matter, and controlling where and in what size the textboxes shall appear. Just to show that it is possible. There is a lot more to it. -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically add a textbox to a user form based on user requireme
Here's one way to do it. Paste this sub routine in your form code module:
Private Sub AddTextBox(iCount As Integer) Dim i As Integer For i = 1 To iCount Me.Controls.Add "Forms.TextBox.1", "txtBox" & i, True 'adjust the textbox position as needed With Me.Controls("txtBox" & i) '10 pixes from the left edge of the form .Left = 10 '20 pixes from the top of the form, '2 pixels between each text box .Top = (i * (.Height + 2)) + 20 End With Next i End Sub Call it in your form by: AddTextBox 3 -- Hope that helps. Vergel Adriano "Brite" wrote: I was wondering if it is possible to automatically add a text box to a user form based on user requirements? I'm trying to make a wizard, and the way i want it to work is: 1. A userform will appear asking how many sources of revenue the user would like to enter. 2. On the next userform i want the appropriate number of text boxes to appear so that the user can enter all of their data. For example. Say a user enters that they would want to enter 3 sources of revenue. On the next screen i want a user form to appear with three textboxes so that they can enter all of their data. Is there a way to do this? thanks in advance for your help! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically add a textbox to a user form based on user requi
This is great, thanks very much for both of your responses!
"Vergel Adriano" wrote: Here's one way to do it. Paste this sub routine in your form code module: Private Sub AddTextBox(iCount As Integer) Dim i As Integer For i = 1 To iCount Me.Controls.Add "Forms.TextBox.1", "txtBox" & i, True 'adjust the textbox position as needed With Me.Controls("txtBox" & i) '10 pixes from the left edge of the form .Left = 10 '20 pixes from the top of the form, '2 pixels between each text box .Top = (i * (.Height + 2)) + 20 End With Next i End Sub Call it in your form by: AddTextBox 3 -- Hope that helps. Vergel Adriano "Brite" wrote: I was wondering if it is possible to automatically add a text box to a user form based on user requirements? I'm trying to make a wizard, and the way i want it to work is: 1. A userform will appear asking how many sources of revenue the user would like to enter. 2. On the next userform i want the appropriate number of text boxes to appear so that the user can enter all of their data. For example. Say a user enters that they would want to enter 3 sources of revenue. On the next screen i want a user form to appear with three textboxes so that they can enter all of their data. Is there a way to do this? thanks in advance for your help! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically add a textbox to a user form based on user requireme
I prefer putting my controls on the userform during design time, so I know
how the form will look. I keep certain ones hidden, then show them (rather than drawing new ones) when needed. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Brite" wrote in message ... I was wondering if it is possible to automatically add a text box to a user form based on user requirements? I'm trying to make a wizard, and the way i want it to work is: 1. A userform will appear asking how many sources of revenue the user would like to enter. 2. On the next userform i want the appropriate number of text boxes to appear so that the user can enter all of their data. For example. Say a user enters that they would want to enter 3 sources of revenue. On the next screen i want a user form to appear with three textboxes so that they can enter all of their data. Is there a way to do this? thanks in advance for your help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Textbox in user form | Excel Programming | |||
Textbox on user form in Excel VBA | Excel Programming | |||
textbox on user form | Excel Programming | |||
User Form in VB = TextBox | Excel Discussion (Misc queries) | |||
Textbox trouble on a user form | Excel Programming |