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) という形式で返します。

適用対象

こちらもご覧ください