2 回答

TA贡献1796条经验 获得超7个赞
Command 函数用于启动 Visual Basic 或使用 Visual Basic 开发的可执行程序的命令行的参数部分。
对于用 Visual Basic 开发的且编译为 .exe 文件的应用程序,Command 函数返回在命令行中出现于应用程序名称后的任何参数,其格式为:MyApp(cmdlineargs)。
示例
此示例使用 Command 函数返回包含数组的对象中的命令行参数。
VB
Function GetCommandLineArgs() As String()
' Declare variables.
Dim separators As String = " "
Dim commands As String = Microsoft.VisualBasic.Interaction.Command()
Dim args() As String = commands.Split(separators.ToCharArray)
Return args
End Function

TA贡献1865条经验 获得超7个赞
添加一个模块文件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()函数收到的文件路径一定是正确才不会出错!
- 2 回答
- 0 关注
- 940 浏览
添加回答
举报