Visual Basic - Separar texto en textbox´s

Life is soft - evento anual de software empresarial
 
Vista:

Separar texto en textbox´s

Publicado por Ortzi (4 intervenciones) el 28/01/2009 10:49:54
Esto es lo que tengo hecho...
me parece que con el split no consigo lo que quiero

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Me.Button1.Text = " Abrir archivo "
End Sub

Function Leer(ByVal path As String) As String
Try
Dim oSR As StreamReader = New StreamReader(path)
Dim a As String
Dim contador As Integer
Dim nombre As String
Dim l As String
Dim tempSTR As String = ""
contador = 0
' lee la primer línea
l = oSR.ReadLine()
While Not l Is Nothing
a = Mid(l, 1, 1)
If a = "1" Then
nombre = Mid(l, 53, 35)
contador = contador + 1
If contador = 1 Then
Me.CheckBox1.Text = nombre
Else
Me.CheckBox2.Text = nombre
End If

tempSTR = tempSTR & l & vbNewLine
l = oSR.ReadLine() ' lee la siguiente
Else
' variable temporal que almacena las líneas
tempSTR = tempSTR & l & vbNewLine
l = oSR.ReadLine() ' lee la siguiente
End If
End While
' cierra y libera los recursos
oSR.Close()
oSR.Dispose()
' retorna el texto
Return tempSTR
' errores
Catch oe As Exception
Return ""
MsgBox(oe.Message)
End Try

End Function

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
' nuevo diálogo
Dim OpenFiledlg As New OpenFileDialog
With OpenFileDialog1
.FileName = ""
.Filter = "Archivos de texto *.txt|*.txt|Todos *.*|*.*"
' abre el diálogo para seleccionar archivo el de texto
.ShowDialog()

If .FileName <> "" Then
TextBox1.Text = Leer(.FileName)
End If
End With
End Sub
End Class

--------------------------------------------------------------------------------------------------------------

este es el textbox que tengo ahora...

1S90200604005200712120037652006010920061231B33456625EXCAVACION 20060400520071212003765 0400520071212003765 000000000 000000000 000000000241
1S90200604005200712120037652006010920061231B33456625EXCAVACION 20060400520071212003765 0400520071212003765 000000000 000000000 000000000241 y lo que necesito es que me introduzca asi...
textbox1..

1S90200604005200712120037652006010920061231B33456625EXCAVACION 20060400520071212003765 0400520071212003765 000000000 000000000 000000000241

textbox2

1S90200604005200712120037652006010920061231B33456625EXCAVACION 20060400520071212003765 0400520071212003765 000000000 000000000 000000000241

separandomelas cuando la primera posicion de la linea sea de valor "1" hasta cuando vuelva a serlo.

igual asi mexplico mejor.
un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Separar texto en textbox´s

Publicado por P3L30N2009 (699 intervenciones) el 28/01/2009 12:52:24
Hola, en este link tienes la respuesta:

http://www.lawebdelprogramador.com/news/mostrar_new.php?id=93&texto=Visual+Basic&n1=522621&n2=1&n3=2&n4=1&n5=0&n6=0&n7=0&n8=0&n9=0&n0=0

Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar