Interaction.Command 方法

定义

返回用于启动Visual Basic或使用 Visual Basic 开发的可执行程序的命令行的参数部分。 此功能 My 提供比 Command 函数更高的工作效率和性能。 有关详细信息,请参阅 CommandLineArgs

public:
 static System::String ^ Command();
public static string Command();
static member Command : unit -> string
Public Function Command () As String

返回

命令行的参数部分,用于启动Visual Basic或使用Visual Basic开发的可执行程序。

此功能 My 提供比 Command 函数更高的工作效率和性能。 有关详细信息,请参阅 CommandLineArgs

示例

此示例使用 Command 函数返回包含数组的对象中的命令行参数。

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

注解

返回参数后,可以搜索常见的分隔符,例如空格、向后斜杠、连字符或引号,以拆分或搜索各个参数的字符串。

对于使用Visual Basic开发并编译为 .exe 文件的应用程序,Command 函数返回命令行上应用程序名称后出现的任何参数,格式如下:MyApp(cmdlineargs)

适用于

另请参阅