Visual Basic Language Reference  

Command Function

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

Public Function Command() As String

Remarks

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, as in this example:

MyApp cmdlineargs

Example

This example uses the Command function to get the command-line arguments in a function that returns them in an object containing an array.

Function GetCommandLineArgs() As String()
   ' Declare variables.
   Dim separators As String = " "
   Dim commands As String = Microsoft.VisualBasic.Command()
   Dim args() As String = commands.Split(separators.ToCharArray)
   Return args
End Function

See Also

Visual Basic Run-Time Library Members | Visual Basic Compiler Options