Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a Startup Parameter

Status
Not open for further replies.

capone67

Programmer
Nov 6, 2000
115
0
0
CA
Hi Gang

I am working on a project where I need to pass a couple of parameters to a VB program when it is starting up. How do I call the program and how do I access the parameters that are passed to it.

TIA

Ken
 
Ken --

Parameters can be passed into a VB application from the command line. You can do this either by starting your program from the Windows run dialog, or you can alter the "Target" property in the Windows shortcut.

For example, the Target property in the shortcut for one of my applications looks something like this:

C:\MyFolder\MyApp.exe /PROD

In the above line , the "/PROD" is a command line parameter -- it gets passed as a string into MyApp.exe at run time. You can have more than one parameter, but your app only captures a single string from the command line. You must parse the command line parameter string yourself.

Use the Command$() function to capture the command line parameter string -- just put the following code in your app's Main() subroutine:

Dim sRunTimeParameters As String
sRuntimeParameters = Command$()

Hope this helps -- WB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top