Command 関数

更新 : 2007 年 11 月

Visual Basic 自体または Visual Basic で開発した実行可能プログラムを起動させるために使用するコマンド ラインの引数の部分を返します。

My 機能は、Command 関数よりも高い生産性とパフォーマンスを実現します。詳細については、「My.Application.CommandLineArgs プロパティ」を参照してください。

Public Function Command() As String

解説

引数が返された後で、空白、バックスラッシュ、スラッシュ、ハイフン、引用符などの一般的なデリミタを検索し、各パラメータを分割、または文字列を検索します。

アプリケーションを Visual Basic で開発したり、EXE ファイルをコンパイルする場合、Command 関数は MyApp(cmdlineargs) のように、コマンド ライン上のアプリケーションの名前の後の引数を返します。

使用例

次に示すのは、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

必要条件

名前空間 : Microsoft.VisualBasic

モジュール : Interaction

アセンブリ : Visual Basic ランタイム ライブラリ (Microsoft.VisualBasic.dll)

参照

概念

Visual Basic バージョンの Hello World!

参照

Visual Basic ランタイム ライブラリのメンバ

Visual Basic プログラムの構造

Environment.GetCommandLineArgs

My.Application.CommandLineArgs プロパティ

その他の技術情報

Visual Basic コンパイラ