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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.