Results 1 to 6 of 6

Thread: Visual Basic 4.0 and Command Line Arguments

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    3
    I am using Visual Basic 4.0 to create executable CGI scripts, which despite the dated technology, works well. In order to streamline the number of executable files that are neccessary, it seems like a good idea to pass command line arguments to each program.

    As an example, I collect data, and then proceed from compiled CGI Data1.exe to Data2.exe.

    Instead, it seems like a great idea to call a Data.exe, followed by some parameter, hence: Data.exe 1, or Data.exe 2.

    Using VB4.0, how do I pass parameters in this way? Does anyone know?

    Thanks!

    Shaun

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325

    Talking

    All command Line parameters are stored in the String 'Command$' So, just parse it up!
    -Shickadance

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    3
    Thanks MrShickadance.

    I guess I am truly a novice. Must I first declare this string, or can it be automatically referenced and stored into a string variable?

    Thanks!

    [Edited by stonstad on 05-23-2000 at 03:42 PM]

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    Nope, it's already defined for you to use. It has to be. Command line args will always be in the Command$ variable.
    -Shickadance

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    3
    Wow, I'd really love for this to work. For some reason though, my cgi prints out the following when I convert $Command to a string and output it:

    "d:\WEBSITE\CGI-TEMP\285WS.INI"

    Any ideas?

  6. #6
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    Nono, the variable "Command$" is the variable name, not "Command" It is already a string, no need to convert.

    so, something like this will work:

    Code:
      
    
      Public Sub Main()
        
        Dim c_list() As String
        Dim i        As Integer
        
        '' command line args, space delim.
        c_list = Split(Command$, " ")
        
        '' display all command line args
        For i = LBound(c_list) To UBound(c_list)
          Call MsgBox(c_list(i))
        Next i
        
      End Sub
    -Shickadance

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