求助:VB中怎样从TXT文件中读取数据,并赋值给二维数组?
通过OpenApp.Path&"\1.txt"ForInputAs#1读取数据但是怎么能把数据读出,并赋值给二维数组?...
通过Open App.Path & "\1.txt" For Input As #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)
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)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询