Command函数


请输入要查询的词条内容:

Command函数


Visual Basic 语言参考

Command 函数

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

My 功能可以提供比 Command 函数更高的效率和更好的性能。有关更多信息,请参见 My.Application.CommandLineArgs 属性。

Public Function Command() As String

备注

参数返回后,您可以搜索常用分隔符(如空格、反斜杠、正斜杠、连字符或引号)断开或搜索单个参数的字符串。

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

示例

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

Visual Basic 复制代码

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

要求

命名空间: Microsoft.VisualBasic

模块: Interaction

程序集: Visual Basic Runtime Library(在 Microsoft.VisualBasic.dll 中)

相关分词: Command 函数