Command Line Arguments - Programmers Heaven

Howdy, Stranger!

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

Categories

Command Line Arguments

fh791fh791 Posts: 35Member
How can I process command line arguments in VB.net???????

Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    : How can I process command line arguments in VB.net???????
    :


    You can get the commandline in string format like so:

    [code]
    Dim cmd As String = Environment.CommandLine
    [/code]

    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:

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

    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.