View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Please HLEP: whats wrong with my code!? Adding textbox as runtime

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