Results 1 to 4 of 4

Thread: command line arguments to vb exe

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Pune, India
    Posts
    1

    Unhappy

    is it possible to send any arguments to a standard exe prepared using vb? if yes, how to use these arguments in the startup modules or forms of the exe?

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Location
    Belgium
    Posts
    77
    Yes it is possible.
    Use the Command() function to get the argument of your program

    Code:
    dim CmdLine as string
    CmdLine = Command()
    ' Treatment of the CmdLine
    ...
    KWell

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Let said you wish your VB program to accept an command line "/%1 /config"

    then all you need is put this under the Sub Main() or Form_Load() procedure.

    Code:
    Option Explicit
    Private MyCmdLine As String
    
    Public Sub Main()
       MyCmdLine = Command()
       If MyCmdLine = "/%1 /config" then
          'Do whatever you've plan.
       Else
          'Do whatever you don't want your program do.
       End If
    End Sub
    Or....
    
    Private Sub Form_Load()
    MyCmdLine = Command()
       If MyCmdLine = "/%1 /config" then
          'Do whatever you've plan.
       Else
          'Do whatever you don't want your program do.
       End If
    End Sub

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Like operator is fast and easy if you want to put flags in your command line:
    Code:
    Public Sub Main()
       MyCmdLine = Command()
       If MyCmdLine like "*/a*" then 'Do what you what
       If MyCmdLine like "*/b*" then 'Do what you what
       If MyCmdLine like "*/c*" then 'Do what you what
       If MyCmdLine like "*/d*" then 'Do what you what
       If MyCmdLine like "*/e*" then 'Do what you what
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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