Open

添加一个模块文件Moudel1
模块代码:
Public Dq as String
Sub Main()
Dq=Command()
End Sub
其他代码不需要,然后把你的代码稍改写一些:
Private Sub Form_Load()
    MsgBox dq‘保留!查看效果
    Dim TextLine
    Open dq For Input As #1 ' 打开文件。
    Do While Not EOF(1) ' 循环至文件尾。
    Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
    Text1.Text = Text1.Text & TextLine & vbNewLine ' 在调试窗口中显示数据。
    Loop
    Close #1 ' 关闭文件。

End Sub
这样就行了,但是要Command()函数收到的文件路径一定是正确才不会出错!

原文地址:https://www.cnblogs.com/piaoyf/p/2442880.html