Hola alguien conoce un codigo que repida los numeros de la siguiente forma
si yo coloco esto en un textbox:
texto
texto
texto
texto
texto
texto
al presionar un boton, el resultado sea el siguiente.
1texto
2texto
3texto
1texto
2texto
3texto
porfavor nesecito realizar esta accion. si alguien conoce sobre este tema se lo agradeceria inmensamente.
Private Sub Command1_Click()
Dim Lineas() As String
Dim i As Integer, NumLinea As Integer
Lineas = Split(Text1.Text, vbNewLine) 'obtiene un array (matriz). Tantos elementos como saltos de línea en Text1
Text1.Text = "" 'Limpia el Text1
NumLinea =0
'Bucle que repite tantas veces como líneas haya en Text1 (elementos de array Lineas)
For i = LBound(Lineas) To UBound(Lineas)
NumLinea = NumLinea + 1 'Obtiene el númer de línea empezando desde 1
If NumLinea = 4 Then NumLinea = 1 'Vuelve a empezar desde 1 si NumLinea = 4
'Reescribe cada línea en el Text1 añadiendo el número de línea
If Lineas(i) <> "" Then Text1.Text = Text1.Text & NumLinea & Lineas(i) & vbCrLf
Next
End Sub
Private Sub Form_Load()
Text1.Text = ""
For N = 1 To 6
Text1.Text = Text1.Text & "Texto" & vbCrLf
Next N
End Sub