G
Guest
I am trying to use the split function to bread up lines in a file I am
reading from. Some lines are working just fine, but a couple of the lines
don't split up the way I would have thought.
Here's part of the code.
Dim strDelim As String = "*~"
Dim delimiter As Char() = strDelim.ToCharArray
Dim split As String() = Nothing
Dim fieldCount As Integer
Dim s As String
split = line.Split(delimiter, line.Split.GetUpperBound(0))
fieldCount = 0
For Each s In split
Dim y As String = s
If y <> "" Then
fieldCount = fieldCount + 1
End If
Next s
strAddress = split.GetValue(fieldCount - 1)
Here's a sample line that works
N3*SU*1685 N MAIN ST~
Here's a line that doesn't work
N3*ST*MAP*24000 Honda Pkwy~
The line that doesn't work breaks after the N3, but it includes everything
else in the second split.
The line that works splits everything fine.
Let me know what I can change, or what I am doing wrong.
reading from. Some lines are working just fine, but a couple of the lines
don't split up the way I would have thought.
Here's part of the code.
Dim strDelim As String = "*~"
Dim delimiter As Char() = strDelim.ToCharArray
Dim split As String() = Nothing
Dim fieldCount As Integer
Dim s As String
split = line.Split(delimiter, line.Split.GetUpperBound(0))
fieldCount = 0
For Each s In split
Dim y As String = s
If y <> "" Then
fieldCount = fieldCount + 1
End If
Next s
strAddress = split.GetValue(fieldCount - 1)
Here's a sample line that works
N3*SU*1685 N MAIN ST~
Here's a line that doesn't work
N3*ST*MAP*24000 Honda Pkwy~
The line that doesn't work breaks after the N3, but it includes everything
else in the second split.
The line that works splits everything fine.
Let me know what I can change, or what I am doing wrong.