Command Line Arguments

How can I process command line arguments in


  • : How can I process command line arguments in

    You can get the commandline in string format like so:

    Dim cmd As String = Environment.CommandLine

    Then you parse it any which way. Of course you can also have your VB.NET application startup from the Main sub-routine instead of a Form:

    Module Example
    Sub Main(ByVal args() as String)
    ' Do stuff.
    ' Parse args array
    ' Run Windows Form object
    End Sub
    End Module

    In this version of the Main function gets passed an array of commandline args when the program is started. The first entry in the array should be the name of the application like myApp.exe. To setup the project to start from the Main routine:

    1. Right-click project name in the solution explorer and choose properties.

    2. For the startup object choose "ub Main" from the drop down.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion