View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
stewart stewart is offline
external usenet poster
 
Posts: 44
Default add multiple controls

i have a form with a Button (commandbutton1) and a textbox (tb2). The
button procedure takes the input in the textbox and uses it to
determine the number of text boxes it should create. The code appears
to work but I wanted to know if anyone can foresee any problems with
the way I have written the procedure. I am teaching myself VB so it
may not be the most effective way of completing the process. here is
the code, any help would be appreciated.

Private Sub CommandButton1_Click()


Dim i As Integer
For i = 1 To tb2.Value Step 1

With Me.Controls.Add("Forms.textbox.1")
.Top = 200 + (20 * i)
.Left = 15
.Height = 20
.Width = 50
.Name = "txt" & i
End With
Next i
End Sub