Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Please HLEP: whats wrong with my code!? Adding textbox as runtime

Sam,

Actually, I think I would create all 10 text boxes at design state,
then hide all 10 when the userform is initialized. Then you just have
to unhide the choosen number of textboxes....

Hopes this helps.
....
Per


On 29 Jan., 22:17, Per Jessen wrote:
Hi Sam

Try this:
just h
Private Sub TextBox1_AfterUpdate()
Dim cCntrl As Control, Dim i as integer
If Me.TextBox1.Value =1 and me.textbox1.value<=10 *Then

With Frame14
for 1=1 to me.textbox1.value

* * Set cCntrl = Me.Controls.Add("Forms.TextBox.1", "MyTextBox1",
True)
* * With cCntrl
* * * * .Width = 150
* * * * .Height = 25
* * * * .Top = 10
* * * * .Left = 10
* * * * .ZOrder (0)
* * End With
next
End With
End If
Next i
End Sub

Regards,
Per

On 29 Jan., 22:05, sam wrote:



Hi All,


I want to add textboxes at runtime based on what user inputs in a textbo.


For eg:


I have a textbox "Total Students" , so Once I input a number in that
textbox, I want to have that many textboxes on the form during run time.. If
I input 4 I want four textboxes to be displayed on the form.


Here is my code that I have so far.


Private Sub TextBox1_AfterUpdate()
Dim cCntrl As Control, Dim i as integer
i = 1


For i = 1 To 10


* * If Me.TextBox1.Value = i Then


* * * * With Frame14


* * Set cCntrl = Me.Controls.Add("Forms.TextBox.1", "MyTextBox1", True)
* * With cCntrl
* * * * .Width = 150
* * * * .Height = 25
* * * * .Top = 10
* * * * .Left = 10
* * * * .ZOrder (0)
* * End With


End With


End If


Next i


End Sub


Thanks in advance- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


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
Whats wrong with my code? [email protected] Excel Programming 4 May 3rd 07 03:47 AM
Whats wrong with this code? Steve[_73_] Excel Programming 2 January 31st 06 04:13 PM
Whats wrong with this code? Joseph[_54_] Excel Programming 2 November 26th 04 04:31 PM
whats wrong with this code LiSa Excel Programming 2 September 8th 04 05:47 PM
Whats wrong with this code gav meredith Excel Programming 5 April 21st 04 12:01 AM


All times are GMT +1. The time now is 08:09 PM.

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

About Us

"It's about Microsoft Excel"