Read/Split

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Read/Split
Dummy1912
Hello,

can anyone give us a great sample for reading a file and split the all lines with a char?

so the files will has for example:
0|test|test

and we wanna split it to add them in separated textboxen

we have this but no idea how to use it with a file to read
so this must be used aswell.
anyone please?
Code: Select all
Dim data As String = Nothing
                Using reader As StreamReader = New StreamReader(ReadFile)
                    Do While Not reader.EndOfStream
                        data &= vbNewLine & reader.ReadLine
                    Loop
                End Using

                For Each codePart As String In data.Split("|")
                    If (codePart.Trim).Length > 0 Then
'here it will be all transfered to split them in text boxen
End If
thank you
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Read/Split
XTechVB
You mean something like this?
Code: Select all
        Using OPF As OpenFileDialog = New OpenFileDialog()
            If (OPF.ShowDialog() = Windows.Forms.DialogResult.OK) Then
                For Each TextLine As String In IO.File.ReadAllText(OPF.FileName).Split("|")
                    If (TextLine.Trim().Length > 0) Then
                        'Do what ever you want with the line
                    End If
                Next
            End If
        End Using
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Read/Split
Dummy1912
hello #XTechVB

well it seems it does nothing :(
i mean it doesn't add them into the text boxen
Code: Select all
For Each TextLine As String In IO.File.ReadAllText(OPF.FileName).Split("|")
                    If (TextLine.Trim().Length > 0) Then
                         AddTextbox(TextLine.Trim)
                         'Do what ever you want with the line
                    End If
                Next

Code: Select all
Public Sub AddTextbox(ByVal text As String)
Dim index As Integer = 0
        Dim Array_ As TextBox() = New TextBox() {Me.e1, Me.e2, Me.e3}
Dim box As TextBox
        For Each box In Array_
            box.Text = text(index)
 index += 1
            Application.DoEvents()
        Next

visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Read/Split
XTechVB
Can you post the full code for the "AddTextbox" function? or send it via pm?
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Read/Split
Dummy1912
Thanks #XTechVB
i fix it
was my fault with your code :lol:
+rep
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
5 posts Page 1 of 1
Return to “Tutorial Requests”