VB.Net string parse


I am new at VB.net so please excuse me.  Will this code work? If not would you correct it for me? I want to show each element in label I have created on a form.

Private Sub read835()
        Dim isaLine As String
        Dim elementSep, compositeSep, segmentSep As String
        Dim x As Integer
        Dim tmp() As String
        isaLine = "ISA*00*          *00*          *27*00523          *ZZ*M4788          *040414*2351*U*00401*410500028*0*P*:~"
        elementSep = isaLine.Substring(103, 1)

        For x = 0 To isaLine.Length
            tmp = Split(isaLine, "*")

        Next
        lblMsg.Text = tmp(x)
 
 
 
lindapatAsked:
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.

Bob LearnedCommented:
Are you thinking about strtok?  If so, then you are a little off there:

tmp = Split(isaLine, "*") will return the ISA, 00, <blank>, 00, <blank>, 27, 00523...  

You only need to do this one, and then reference the element that you need.

Bob
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
DabasCommented:
Hi lindapat,
You say you want to show each element in the label you have created on a form.
Sounds like a contradiction to me.
How can you show multiple elements in one label?

Otherwise I agree with Bob:
Take split out of the loop.
Maybe display the label with the loop.
Something like:

tmp = Splig(isaLine,"*")

For x = 0 to UBound(tmp)
    MessageBox.Show(tmp(x))
Next

Dabas
0
J_MakCommented:
One of you problems is that you are attempting to show all items in just the one label. THis will have the effect of placing each string into the label in a very quick manner, in which case you will probably not even notice any of them, except the last one which will remain as the label's text. You could iterate through each element of your resultant array and put them in a list box or something, so that it is clear which elements have been split. Otherwise, just use a messagebox. Cheers.
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.