Ver Mensaje Individual
  #12 (permalink)  
Antiguo 02/06/2005, 09:07
sdemingo
 
Fecha de Ingreso: noviembre-2003
Ubicación: Madrid
Mensajes: 109
Antigüedad: 20 años, 6 meses
Puntos: 0
Entonces lo que quieres es crear controles en tiempo de ejecución, en tu caso textbox en la medida que los vayas necesitando.
Te paso un código que crea listbox en tiempo de ejecución, puedes adecuarlo a lo que necesitas.
Código:
Dim oLabel As Label
Private WithEvents oCommand As CommandButton
Private WithEvents oCommand2 As CommandButton
Private WithEvents oListBox As ListBox
Private WithEvents oTimer As Timer


Private Sub Form_Load()
Me.WindowState = vbMaximized

Set oTimer = Me.Controls.Add("VB.Timer", "oTimer", Me)
oTimer.Interval = 100
oTimer.Enabled = True

Set oLabel = Me.Controls.Add("VB.Label", "Label1", Me)
oLabel.Top = 10
oLabel.Left = 10
oLabel.Height = 255
oLabel.Caption = "Crear 10 listboxes como prueba"
oLabel.Width = Me.TextWidth(oLabel.Caption) + 100

Set oCommand = Me.Controls.Add("VB.CommandButton", "oCommand", Me)
oCommand.Top = oLabel.Top
oCommand.Left = (oLabel.Left + oLabel.Width) + 100
oCommand.Height = 255 * 1.5
oCommand.Caption = "Crear ListBoxes"
oCommand.Width = Me.TextWidth(oCommand.Caption) * 1.5

Set oCommand2 = Me.Controls.Add("VB.CommandButton", "oCommand2", Me)
oCommand2.Top = oLabel.Top
oCommand2.Left = (oCommand.Left + oCommand.Width) + 100
oCommand2.Height = 255 * 1.5
oCommand2.Caption = "Eliminar ListBoxes"
oCommand2.Width = Me.TextWidth(oCommand2.Caption) * 1.5

oLabel.Visible = True
oCommand.Visible = True
oCommand2.Visible = True
oCommand2.Enabled = False
End Sub

Private Sub oCommand_Click()
Dim cName As String
Dim nCount As Long
Dim nListBox As Long

oCommand.Enabled = False

For nListBox = 1 To 10

cName = "ListBox_" & nListBox
Set oListBox = Me.Controls.Add("VB.ListBox", cName, Me)

If nListBox <= 1 Then
oListBox.Top = oCommand.Top + oCommand.Height + 10
oListBox.Left = oLabel.Left
oListBox.Width = oLabel.Width * 1.5
Else
cName = "ListBox_" & (nListBox - 1)
oListBox.Top = Me.Controls(cName).Top + Me.Controls(cName).Height + 10
oListBox.Left = Me.Controls(cName).Left
oListBox.Width = Me.Controls(cName).Width
End If
oListBox.Height = 255 * 3
For nCount = 0 To nListBox
oListBox.AddItem "Elemento " & nCount
Next
oListBox.Visible = True
Next

oCommand2.Enabled = True
oCommand2.SetFocus

End Sub

Private Sub oCommand2_Click()
Dim nListBox As Long
For nListBox = 1 To 10
cName = "ListBox_" & nListBox
Me.Controls.Remove cName
Next
oCommand2.Enabled = False
oCommand.Enabled = True
End Sub

Private Sub oListBox_Click()
MsgBox "oListBox.Name = " & oListBox.Name
End Sub

Private Sub oTimer_Timer()
Static cLastLB As String

If Left(Me.ActiveControl.Name, 7) = "ListBox" Then
If Not cLastLB = Me.ActiveControl.Name Then
cLastLB = Me.ActiveControl.Name
Set oListBox = Me.Controls(cLastLB)
oListBox_Click
End If
End If
End Sub
salu2 ;)
__________________
Lo importante no es saber, sino tener el teléfono del que sabe :risa: