Cuadro de texto en un marco

Balou -  
 Balou -
Bonjour à tous, necesito su ayuda y aprender
Novato en VBA, estoy buscando construir un archivo en el que quiero utilizar un userform.
Después de una búsqueda en la red, he realizado un userform en el que se muestran, según una variable, varios textbox.
Hasta ahora todo funciona.
Ahora me gustaría que los textbox se integren en un frame.
Pero los textbox se muestran fuera del frame

Aquí está el código, gracias por sus sugerencias.

Incr = 8
PosX = 120

For i = 1 To nbcells 'bucle para la creación de los TextBox

Set Obj = Me.Controls.Add("forms.Frame.1")
With Obj
.Caption = "TRACABILIDAD"
.Font.Bold = True
.Left = 6
.Top = 126
.Width = 114
.Height = 100

Set Obj = Me.Controls.Add("forms.TextBox.1")
With Obj
.Name = "TextBox" & i
.Object.Value = " "
.Left = PosX
.Top = 30 * ((i - 1) Mod 10) + 40
.Width = 100
.Height = 20
End With

'adición del objeto en la clase
Set Cl = New Clase1
Set Cl.TextBox = Obj
Collect.Add Cl
If i Mod 10 = 0 Then PosX = PosX + 150
Incr = Incr + 1
End With
Next i


Gracias por su ayuda, que tengan un buen día.

4 respuestas

  1. thev Mensajes publicados 2005 Fecha de registro   Estado Miembro Última intervención   721
     
    Esto debería funcionar mejor


    Set Frame1 = Me.Controls.Add("forms.Frame.1")
    With Frame1
    .Caption = "TRACABILITE"
    .Font.Bold = True
    .Left = 6
    .Top = 126
    .Width = 114
    .Height = 100
    End With
    For i = 1 To nbcells
    Set Obj = Frame1.Controls.Add("forms.TextBox.1")
    With Obj
    .Name = "TextBox" & i
    .Object.Value = " "
    .Left = PosX
    .Top = 30 * ((i - 1) Mod 10) + 40
    .Width = 100
    .Height = 20
    End With
    Next i


    --
    1
  2. thev Mensajes publicados 2005 Fecha de registro   Estado Miembro Última intervención   721
     
    Hola,

    Prueba esto

    Set Obj = Me.Controls.Add("forms.Frame1")
    With Obj
    .Caption = "TRACABILITE"
    .Font.Bold = True
    .Left = 6
    .Top = 126
    .Width = 114
    .Height = 100
    End With
    Set Obj = Me.Frame1.Controls.Add("forms.TextBox0")
    With Obj
    .Name = "TextBox" & i
    .Object.Value = " "
    .Left = PosX
    .Top = 30 * ((i - 1) Mod 10) + 40
    .Width = 100
    .Height = 20
    End With

    --
    0
  3. Balou
     
    Gracias thev por tu publicación, pero tu propuesta no funciona.

    Esta línea crea un error si dejo TextBox0
    Set Obj = Me.Frame1.Controls.Add("forms.TextBox0")


    He probado con TextBox.1 y no hay más errores, pero los TextBox ya no se muestran.

    Sigo buscando por mi parte.

    Espero su respuesta, gracias por su ayuda.
    0
  4. Balou
     
    Hola thev, esta solución funciona.

    Gracias por tu apoyo.
    0