read each line from text box

I have a variable that contains the following contents:
HH|N|S00001-L10|CC|RBTW|0
HR|PO|PO Number
HN|Notes
SS|P|5555|WarehouseName|555 Address1|Address2|City|MN|55444|US|ContactName|ContactPhone|20110614|0524|
SR|PU|PickupNumber
SN|Notes
II|Item Description|555SKU|25|EA|4200|LB|25|USD
SS|D|2222|Warehouse Name|555 Address1|Address2|City|St|55444|US|
SR|DO|DeliveryNumber
SN|Notes
II|Item Description|555SKU|25|EA|4200|LB|25|USD
IN|Notes

Open in new window


I would like to learn how to get the array file content lines and separate each line in two parts, I will use the first line as example:

Get this part of each line (first two characters) >> HH
Then the whole line, including the fist two characters >> HH|N|S00001-L10|CC|RBTW|0

Each line is delimited at the end by a LF or a CR LF

I need to loop through each line and call a function that will eventually do something with these two values.

Is it possible to ask for help an a example if code that can do this work?

Any help or direction to examples would be great.

Thank you!
metropiaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

metropiaAuthor Commented:
I tried to do this:

            Dim arg() As String = {ControlChars.CrLf, ControlChars.Lf}
            Dim FileLines As String = inFileContents.Split(arg, StringSplitOptions.None)(0)


            For Each Line As String In FileLines

                Console.WriteLine(Line)

            Next

Open in new window


but that loops through each character on the line

H then H, then | then N Then | and so on

I need to go line by line :/
0
metropiaAuthor Commented:
I think I got it:

            FileId = myRecord.FileId

            Dim arg() As String = {ControlChars.CrLf, ControlChars.Lf}

            For Each line In inFileContents.Split(arg, StringSplitOptions.None)

                Console.Write(line)

                Dim objFtpFileLine As New FtpFileLineClass()
                outStatusString = objFtpFileLine.Upload_FromLineStringToDatabase(FileId, inLineNumer, line)

            Next

Open in new window


One question, how can I pass a counter for each line i.e. "inLineNumber"
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Something like:
        Dim lines() As String = inFileContents.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
        For i As Integer = 0 To lines.Length - 1
            Dim objFtpFileLine As New FtpFileLineClass()
            outStatusString = objFtpFileLine.Upload_ToDatabase(FileId, i, lines(i))
        Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mel-Leo RosalCommented:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim str() As String

        For Each line In TextBox1.Text.Split(vbCrLf)
            str = line.Split("|")

            MsgBox(str(0)) 'first two
            MsgBox(line) 'the whole line

            'lolvar = lolfunc(str(0),line) 'function sample

        Next

    End Sub

Open in new window


something like this?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.