CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Command Prompt

  1. #1
    Join Date
    Mar 2001
    Posts
    26

    Command Prompt

    Hi

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

    Thanks

    Ehsan



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Command Prompt

    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.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Apr 2000
    Posts
    737

    Re: Command Prompt

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured