我自己解决了...
int1 = CInt(line.Split(CChar(","))(1))
要逐行读取文本文件的内容,我正在使用此代码
Using r As StreamReader = New StreamReader("0trace2.txt")
Dim line As String
line = r.ReadLine
Do While (Not line Is Nothing)
list.Add(line)
line = r.ReadLine
MsgBox(line)
Loop
End Using
但是,该文件有 4 个逗号分隔值,所有数字。我需要将每个数字提取为整数。我尝试了拆分方法,但遇到了错误
Dim int1 as Integer
Dim int2 as Integer
Dim int3 as Integer
Dim int4 as Integer
Using r As StreamReader = New StreamReader("0trace2.txt")
Dim line As String
line = r.ReadLine
Do While (Not line Is Nothing)
list.Add(line)
line = r.ReadLine
'MsgBox(line)
int1 = CInt(line.Split(CChar(","))(1))
Loop
End Using
谢谢