Add Command Line Options To Your Application

Let the user launch your application from DOS or from Start Menu->Run with command line options, like "yourapp.exe option1".

This simple example will show you how to retrieve to command line option.
Enter the following code to your form, compile your Project to exe file, and from DOS or from Start Menu->Run launch the exe file with command line argument, like "yourapp.exe option1", and
a message box will pop up with the command line argument you've entered.

Note: instead of launching your code from DOS every time you want to test it, you can run it as usual from Visual Basic Environment, by entering the command line argument to your project this way:

In VB 5.0/6.0: From the menu choose Project->Project1 Properties, click on Make tab, and enter you Command Line argument in the Command Line Arguments text box.

In VB 4.0 the Command Line Arguments text box found in Tools->Option, then clikc on the Advanced Tab.

In VB 3.0 the Command Line Arguments text box found in Options->Project

Form Code

Private Sub Form_Load()
    MsgBox Command
End Sub

Go Back