Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
  Tip: Make a shortcut that passes a program command line parameters  
 
 

In Visual Basic 6, you can use the Command$ function to read the program's command line parameters. See List a program's command-line arguments.

In Visual Basic .NET, you can use the Main subroutine's argument parameter (see List a VB .NET program's command-line arguments) or My.Application.CommandLineArgs (see Read command line parameters in VB 2005).

But how do you pass the program those parameters? Three useful ways include:

  1. Launch the program from a command prompt, adding the parameters at the end. This is useful if you will be using the program from the command line.
  2. Open the Project menu and select Properties at the bottom. Enter command line arguments on the Debug tab.
  3. Create a shortcut that passes the parameters to the program. Right-click the desktop and select "New > Shortcut." When it asks for the item's location, type in the full file name (surrounded by quotes if it contains spaces and other oddities) followed by the command line arguments.

Note that it is fairly common in complex projects with multiple versions to use the same program for multiple purposes and make the program check the command line parameters to see how it should behave. For example, you might build an order system that displays a different interface for order entry clerks and shipping clerks. You can pass the program a parameter to tell it which way it should behave.

 

Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated