这是我到目前为止所拥有的
数组大小为(199,2)
该文件包含如下所示的行:Canada,34026478,12938494 USA,3377786,5345678
Sub LoadFromFile(filename As String)
Dim Reader As StreamReader = File.OpenText(filename)
Dim Currentline As String
Dim lineArray() As String
Do While Reader.EndOfStream = False
Currentline = Reader.ReadLine
lineArray = Currentline.Split(","c)
Loop
Using sr As StreamReader = New StreamReader(filename)
Do While sr.Peek() >= 0
For Each c As Char In sr.ReadLine.Split
Try
ValuesFromFile(y, x) = CStr(Integer.Parse(c))
Catch ex As Exception 'i assume this is the only possible error, but we could be out of bounds due to assuming the actual size of the file/line... catch specific exceptions as necessary'
End Try
y += 1
Next
x += 1
y = 0
Loop
End Using
Reader.Close()
End Sub