Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox in user form Curt Excel Programming 2 February 20th 07 12:45 AM
Textbox on user form in Excel VBA Gimp Excel Programming 4 January 16th 07 05:34 PM
textbox on user form Mike Excel Programming 3 December 2nd 05 04:43 PM
User Form in VB = TextBox Kel Excel Discussion (Misc queries) 1 August 11th 05 12:26 AM
Textbox trouble on a user form Oreg[_3_] Excel Programming 7 May 27th 04 12:36 AM


All times are GMT +1. The time now is 05:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"