如何在vb6中用多个参数调用exe文件

如何在vb6中用多个参数调用exe文件,vb6,Vb6,我尝试了以下代码 Dim pthName As String Dim Parms As String Dim RpNo As Integer Dim glngbr As Long Dim PrtVw As String pthName = "D:\Sample.exe" RpNo = 1 PrtVw = "V" glngbr = 84003 Shell pthName & Parms 我收到错误“运行时错误53” 我试过了,但没有参数 Shell pthName 你可以这样用 She

我尝试了以下代码

Dim pthName As String
Dim Parms As String
Dim RpNo As Integer
Dim glngbr As Long
Dim PrtVw As String
pthName = "D:\Sample.exe"
RpNo = 1
PrtVw = "V"
glngbr = 84003
Shell pthName & Parms
我收到错误“运行时错误53”

我试过了,但没有参数

Shell pthName
你可以这样用

Shell "D:\Sample.exe" & " " & Param_1, Param_2
试试这个:

Shell "D:\Sample.exe" & " " & RpNo & " " & PrtVw & " " & glngbr
使用api shellexecute


您不需要使用Shell命令,也不需要使用ShellExecute。有一个更简单的解决方案:全局
VBA.Command
对象包含调用exe文件时添加的任何字符串。例如,如果在命令行中输入
myproject.exe hello world
VBA.command
将包含字符串
hello world

如果需要多个命令行参数,可以将它们全部放在命令行上,并用一个已知的分隔符分隔,如
/
。然后您可以使用Split函数将它们拆分

阅读。它将告诉您有关它的所有信息,包括如何在IDE中使用它而不必对编译版本进行测试。

Shell“D:\Sample.exe”和“&RpNo,PrtVw,glngbr。我收到错误“参数数目错误或属性分配无效”可能是的重复项
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
                    ByVal hwnd As Long, _
                    ByVal lpOperation As String, _
                    ByVal lpFile As String, _
                    ByVal lpParameters As String, _
                    ByVal lpDirectory As String, _
                    ByVal nShowCmd As Long) As Long

Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2

private Sub exec_program()
    ShellExecute App.hInstance, "Open", "D:\Sample.exe", "Parms", "C:\", SW_SHOWNORMAL
End Sub