这是我要拆分的文本行,data.txt(一些文本文件)
AAEJEY CONSUMER COMPANY 61469 HH13811 4796000501758 NILMA LIQUID BLUE 240 75ML 960.00 20131002
EVERGREEN MARKETING 61485 PC21946 3014260818685 ORALB 7 BENEFITS T/BRUSH 12 EACH 120.00 20131002
HARISCHANDRA MILLS PLC 61488 BV50201 4792083040122 HARISCHANDRA COFFEE 40 50GR 4000.00 20131002
'COMPANY' 和 '61469' 之间的空格长度可能因行而异。 我想将该行拆分如下。
AAEJEY 消费品公司
61469
HH13811
4796000501758
尼尔玛液体蓝
240
75ML
960.00
20131002
这是我的代码,它用空格分隔,但我无法将公司名称(AAEJEY CONSUMER COMPANY)作为单一名称或项目名称(NILMA LIQUID BLUE)作为单一名称。
Dim myArray() As String, delimiter As Char = " "
Dim strBuild As String = ""
Dim b As Boolean = False
Dim i As Integer = 0
Try
Using sr As New StreamReader(fileName)
Dim line As String
While Not sr.EndOfStream
line = sr.ReadLine()
Console.WriteLine(line)
myArray = line.Split(delimiter)
Dim order As New OrdData()
For index As Integer = 0 To myArray.Length - 1
If myArray(index) = "" Then
i = index
myArray.Skip(1)
Else
strBuild += myArray(index) + " "
Console.WriteLine(strBuild)
End If
Next
End While
End Using
Catch e As Exception
Console.WriteLine("The file could not be read:")
Console.WriteLine(e.Message)
End Try