Export (0) Print
Expand All

Interaction.Command Method

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 My.Application.CommandLineArgs Property.

Namespace: Microsoft.VisualBasic
Assembly: Microsoft.VisualBasic (in microsoft.visualbasic.dll)

public:
static String^ Command ()
public static String Command ()
public static function Command () : String
Not applicable.

Return Value

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 My.Application.CommandLineArgs Property.

For more detailed information, see the Visual Basic topic Command Function.

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).

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft