| Tengo en un listbox lo siguiente: 1 2 3 4 5 6 7 8 9 10 11 | Y quisiera pasarlo al Textbox de la siguiente manera: 12345 678910 11 |
For i = 0 To List2.ListCount
If Text4.Text = "" Then
Text4.Text = List2.List(i)
Else
Text4.Text = Text4.Text & vbNewLine & List2.List(i)
End If
Next i
Private Sub Command2_Click()
Inicio = 1
Final = 5
TuCadena = Text1.Text
TotalLineas = Int(Len(TuCadena) / Final) + 1
For xi = 1 To TotalLineas
xTexto = Trim(Mid(TuCadena, Inicio, Final))
Inicio = (xi * Final) + 1
List1.AddItem xTexto
Next xi
End Sub
Justamente hoy pregunte mas o menos sobre esto y el amigo Yban me paso esto y creo que te va a servir tambien a vos.Código: (VB) [Seleccionar]Private Sub Command2_Click()
Inicio = 1
Final = 5
TuCadena = Text1.Text
TotalLineas = Int(Len(TuCadena) / Final) + 1
For xi = 1 To TotalLineas
xTexto = Trim(Mid(TuCadena, Inicio, Final))
Inicio = (xi * Final) + 1
List1.AddItem xTexto
Next xi
End Sub
Private Sub Form_Load()
'Llenamos el ListBox con datos de prueba
Dim i As Integer
For i = 1 To 100
List1.AddItem i
Next i
'Llenamos el Textbox
Dim a As Integer
For i = 0 To List1.ListCount
If a = 5 Then
a = 0
Text1.Text = Text1.Text & i & vbNewLine
Else
Text1.Text = Text1.Text & i
End If
a = a + 1
Next i
End SubPrivate Sub Form_Load()
'Llenamos el ListBox con datos de prueba
Dim i As Integer
For i = 1 To 100
List1.AddItem i
Next i
'Llenamos el Textbox
For i = 1 To List1.ListCount
Text1.Text = Text1.Text & List1.List(i - 1)
If i Mod 5 = 0 Then Text1.Text = Text1.Text & vbNewLine
Next i
End Sub