请问 VB 如何实现顺序读取文本文件中的数据,并将读取到的数据保存在二维数组呢
现在有一组文本文件保存的数据(一个是8行3列),我想实现由VB顺序读取其中的每一个数据,然后保存到二维数组中,再由二维数组将数据添加到MSHFlexGrid控件的表格里,下面是我编的程序,但是最后只能读出第一行,恳请大家看看到底是哪出错了(最后希望读出的也是8行3列才对),谢谢大家!程序如下:
Option Base 1
Private Sub Command1_Click()
Dim i As Long, j As Long, a() As Double
Open "C:\Users\lenovo\Desktop\测试数据.txt" For Input As #1
ReDim Preserve a(1 To 8, 1 To 3)
For i = 1 To 8
For j = 1 To 3
Input #1, a(i, j)
Next j
Next i
Close #1
For i = 1 To 8
For j = 1 To 3
MSHFlexGrid1.TextMatrix(i - 1, j - 1) = a(i, j)
Next j
Next i
End Sub