这是从 txt 中读取二维数组,但是老报错:下标越界, 求大神解救!!!谢谢!我的二维数组大概有 50*6 左右
Private Sub Command1_Click()Dim str1() As String
Dim str2() As String
Dim arr() As String
Dim rows As Integer
Dim cols As Integer
Dim i As Integer
Dim j As Integer
Open "c:\in.txt" For Input As #1
rows = 0
Do Until EOF(1)
rows = rows + 1
ReDim Preserve str1(rows) As String
Line Input #1, str1(rows)
cols = UBound(Split(str1(rows), ","))
Loop
Close #1
ReDim arr(rows, cols) As String
For i = 1 To rows
str2 = Split(str1(i), ",")
For j = 0 To cols
arr(i, j) = str2(j)
Print "arr(" & i & "," & j & ")=" & arr(i, j),
Next
Next
End Sub