lindapat
asked on
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*41050
elementSep = isaLine.Substring(103, 1)
For x = 0 To isaLine.Length
tmp = Split(isaLine, "*")
Next
lblMsg.Text = tmp(x)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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