求助:VB中怎样从TXT文件中读取数据,并赋值给二维数组?

2024-11-07 10:43:04
推荐回答(1个)
回答1:

Public Function openfile(ByVal filepath As String) As String
Dim s As String
Open filepath For Input As #1
While Not EOF(1)
Line Input #1, sline
s = s & sline & vbCrLf
Wend
Close #1
openfile = s
End Function

如果是按一行一行读取进数组 你可以用

dim a
a = split(openfile(App.Path & "\1.txt"),vbcrlf)