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.
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$()
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.