Como acomodar 100 textbox en tiempo de ejecución ?

Hola, como estas? Tengo un pequeño inconveniente, tengo que generar 100 textbox en tiempo de ejecucion y amodarlas en forma de cuadricula (10 x 10), usando la menor cantidad de codigo posible. Si me podes ayudar a achicar el codigo te lo agradeceria.
Yo ya hice uno pero es muy largo, es este:
Private Sub Command1_Click()
For a = 1 To 99
Load Text1(a)
Text1(a).Visible = True
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
If a = 10 Then
Text1(a).Top = (Text1(0).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(0).Left
End If
If a > 10 And a < 20 Then
Text1(a).Top = Text1(0).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 20 Then
Text1(a).Top = (Text1(10).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(10).Left
End If
If a > 20 And a < 30 Then
Text1(a).Top = Text1(10).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 30 Then
Text1(a).Top = (Text1(20).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(20).Left
End If
If a > 30 And a < 40 Then
Text1(a).Top = Text1(20).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 40 Then
Text1(a).Top = (Text1(30).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(30).Left
End If
If a > 40 And a < 50 Then
Text1(a).Top = Text1(30).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 50 Then
Text1(a).Top = (Text1(40).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(40).Left
End If
If a > 50 And a < 60 Then
Text1(a).Top = Text1(40).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 60 Then
Text1(a).Top = (Text1(50).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(50).Left
End If
If a > 60 And a < 70 Then
Text1(a).Top = Text1(50).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 70 Then
Text1(a).Top = (Text1(60).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(60).Left
End If
If a > 70 And a < 80 Then
Text1(a).Top = Text1(60).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 80 Then
Text1(a).Top = (Text1(70).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(70).Left
End If
If a > 80 And a < 90 Then
Text1(a).Top = Text1(70).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
If a = 90 Then
Text1(a).Top = (Text1(80).Top + Text1(0).Height) + 10
Text1(a).Left = Text1(80).Left
End If
If a > 90 And a < 100 Then
Text1(a).Top = Text1(80).Top + 510
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
Next a
End Sub
Respuesta
1
Dim a As Integer
Dim p As Double
For a = 1 To 99
Load Text1(a)
Text1(a).Visible = True
Text1(a).Text = "Text1(" + CStr(a) + ")"
p = a
Do While p >= 10
p = p - 10
Loop
If p = 0 Then
Text1(a).Top = (Text1(a - 10).Top + Text1(a - 10).Height) + 10
Text1(a).Left = Text1(a - 10).Left
Else
Text1(a).Top = (Text1(a - 1).Top)
Text1(a).Left = (Text1(a - 1).Left + Text1(a - 1).Width) + 10
End If
Next a

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas