Export (0) Print
Expand All

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 return the command-line arguments 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

Requirements

Namespace: Microsoft.VisualBasic

Module: Interaction

Assembly: Microsoft.Visual Basic .NET Runtime (in MicrosoftVisualBasic.dll)

See Also

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

Show:
© 2014 Microsoft