vb.net 读取txt文件的有关问题

vb.net 读取txt文件的问题
比如某一行为
111 123 234 345
空格数不定,我怎么用split,从而得到这4个数呢?

------解决方案--------------------
用正则表达式分割空格
------解决方案--------------------
给你一种最简便的方法(这里说最简便是因为这是VS提供生成的,右键--插入代码段 就可以直接生成)

 Dim filename As String = "C:\Test.txt"
Dim fields As String()
Dim delimiter As String = "这里写你的分隔符"
Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)
While Not parser.EndOfData
' Read in the fields for the current line
fields = parser.ReadFields()
' Add code here to use data in fields variable.

End While
End Using
------解决方案--------------------
给你一段代码你试一下:
Dim ss As String = "111 222 333 444 555 666"
Dim s1() As String = ss.Split(CChar(" "))
Dim str As String = ""
For i As Integer = 0 To s1.Length - 1
If s1(i) <> "" Then
str += IIf(i = s1.Length - 1, s1(i), s1(i) & ",")
End If
Next
Dim StrTrim() As String = str.Split(CChar(","))
MsgBox(StrTrim.Length)
------解决方案--------------------
首先用一个递归函数,把多空格替换为单空格

Function SPC(byval strTmp as String) as String

strTmp = Replace(strTmp," "," ")

If Instr(strTmp," ")>0 then
Return SPC(strTmp)
Else
Return strTmp
End if



End Function
------解决方案--------------------
Dim st As String = "111 123 234 345 "
Dim sttb As String() = st.Split(" ")
For i As Integer = 0 To sttb.Length - 1
If Not sttb(i) = "" Then
Dim Newsttb As String = sttb(i)
End If
Next
------解决方案--------------------
探讨
先用 Replace(" ", " ") 将多个空格替换为一个空格

如果多个空格的数量有限,就多写几个Replace(" ", " ")语句

无限则用循环

------解决方案--------------------
楼上各位都咋了,有这么麻烦吗?
又是替换,又是正则的,有必要吗?
String.Split方法不就完了吗?
如果有多个空格,这个方法不是有个重载形式吗?指定StringSplitOptions.RemoveEmptyEntries不就完了吗?
敢情这年头流行曲线救国?
汗.....
------解决方案--------------------
VB.NET code
Dim test As String = "111 123  234    345"
Dim result() As String = test.Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)

For Each s As String In result
    RichTextBox2.Text += s + vbCrLf
Next