Hi
I want to know how can I write a program using VB
that can parse command line parameters.
Thanks
Ehsan
Printable View
Hi
I want to know how can I write a program using VB
that can parse command line parameters.
Thanks
Ehsan
Add a Sub Main to your project and use that as startup. In the sub main, there's a variable you can access, namely Command$. This will contain everything wich comes after the exe name.
If you do
myprogram.exe /p /f'myfile.txt'
then Command$ would be
/p /f'myfile.txt'
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
in vb, the are some functions which can faciliate the parsing, i.e. inStr, inStrRev, Mid, etc.
If you want a ready one, try
http://vblib.virtualave.net
you can use the GetArg function in the vbSystem class. you need to pass in the command argument as well as the argument no that you required.
for instance, if you argument string is "Dir /ON /S". then when you pass in argument no 2, it will return "/S"
hope this help.