RE:cómo aplicar el mismo código a distintas matric
Sigue sin salirme. El objetivo es que al clickar el botón cmd(0) lea el nº de objetos a crear en el textbox txtNumSup, y cree esos controles en los 3 frames.
He probado esto:
Private Sub cmd_Click(Index As Integer)
Select Case Index
Case 0
CrearControles lbl1, txt1
CrearControles lbl2, txt2
CrearControles lbl3, txt3
End Select
End Sub
Donde CrearControles es un sub que he metido en un módulo:
Public Sub CrearControles(lbl1 As Label, txt1 As TextBox)
lbl1(0).Visible = True
txt1(0).Visible = True
Do
i = lbl1.Count
If i < 10 Then
Load lbl1(i)
With lbl1(i)
.Top = lbl1(i - 1).Top + 440
.Caption = i + 1
.Visible = True
End With
i = txt1.Count
Load txt1(i)
With txt1(i)
.Top = txt1(i - 1).Top + 440
.Visible = True
End With
ElseIf i = 10 Or i = 20 Then
Load lbl1(i)
With lbl1(i)
.Left = lbl1(i - 1).Left + 880
.Caption = i + 1
.Visible = True
End With
i = txt1.Count
Load txt1(i)
With txt1(i)
.Left = txt1(i - 1).Left + 880
.Visible = True
End With
ElseIf i > 10 And i <> 20 Then
Load lbl1(i)
With lbl1(i)
.Top = lbl1(i - 1).Top + 440
.Left = lbl1(i - 1).Left
.Caption = i + 1
.Visible = True
End With
i = txt1.Count
Load txt1(i)
With txt1(i)
.Top = txt1(i - 1).Top + 440
.Left = txt1(i - 1).Left
.Visible = True
End With
End If
DoEvents
Loop Until i + 1 = Val(txtNumSup.Text)
End Sub
Pero me da el siguient error: "Error de compilación. Se esperaba una variable o un procedimiento, no un módulo."
¿Qué estoy haciendo mal?