Click to See Complete Forum and Search --> : Command Prompt


Ehsan
March 27th, 2001, 03:49 AM
Hi

I want to know how can I write a program using VB
that can parse command line parameters.

Thanks

Ehsan

Cakkie
March 27th, 2001, 03:57 AM
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
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

cksiow
March 27th, 2001, 04:02 AM
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.