Επεξεργασία

Κοινή χρήση μέσω


Interaction.Command Method

Definition

Returns the argument portion of the command line used to start Visual Basic or an executable program developed with Visual Basic. The My feature provides greater productivity and performance than the Command function. For more information, see CommandLineArgs.

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

Returns

The argument portion of the command line used to start Visual Basic or an executable program developed with Visual Basic.

The My feature provides greater productivity and performance than the Command function. For more information, see CommandLineArgs.

Examples

This example uses the Command function to return the command-line arguments in an object that contains an array.

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

Remarks

After the arguments are returned, you can search for common delimiters, such as spaces, backward or forward slashes, hyphens, or quotation marks, to split or search the string for individual parameters.

For applications developed with Visual Basic and compiled to an .exe file, the Command function returns any arguments that appear after the name of the application on the command line, in this form: MyApp(cmdlineargs).

Applies to

See also