Interaction.Command 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳用於啟動 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)。