Results 1 to 3 of 3

Thread: Command line input to vb exe- RESOLVED

  1. #1
    error40501
    Guest

    Question Command line input to vb exe- RESOLVED

    I couldn't find any references to command line input to a VB exe anywhere in the MSDN CDs or at Microsoft. An associate told me about the 'command' string which one needs to parse for parameters.

    But I'm curious to know where this is documented- I certainly can't find it. Anyone know please?

    Is there some standard way of dealing with the resulting string, or does each programmer typically handle this individually? Are there any recommended rules for switches and so on?

    Thanks all.

  2. #2
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Edinburgh, Scotland
    Posts
    272

  3. #3
    error40501
    Guest

    If there are multiple spaces

    If there are multiple spaces in the command line, like -f myfile then the code in the tutorial doesn't work, because it treats each space as a token.

    In Gary Cornell's VB6 book, he implements what he calls a SuperTrim, which iteratively replaces each spacespace with just a space until there is none left.

    Here it is:

    VB Code:
    1. Public Function SuperTrim(TheString As String) As String
    2. 'Gary Cornell p356
    3.  
    4. Dim Temp As String
    5. Dim DoubleSpaces As String
    6.  
    7. DoubleSpaces = Chr(32) & Chr(32)
    8. Temp = Trim(TheString)
    9. Temp = Replace(Temp, DoubleSpaces, Chr(32))
    10.  
    11. Do Until InStr(Temp, DoubleSpaces) = 0
    12.    Temp = Replace(Temp, DoubleSpaces, Chr(32))
    13. Loop
    14.  
    15. SuperTrim = Temp
    16.  
    17. End Function

    and then change the code in the tutorial thusly:

    VB Code:
    1. a_strArgs = Split(SuperTrim(Command$), " ")
    2. 'supertrim the command string before splitting it

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