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.
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:
Public Function SuperTrim(TheString As String) As String
'Gary Cornell p356
Dim Temp As String
Dim DoubleSpaces As String
DoubleSpaces = Chr(32) & Chr(32)
Temp = Trim(TheString)
Temp = Replace(Temp, DoubleSpaces, Chr(32))
Do Until InStr(Temp, DoubleSpaces) = 0
Temp = Replace(Temp, DoubleSpaces, Chr(32))
Loop
SuperTrim = Temp
End Function
and then change the code in the tutorial thusly:
VB Code:
a_strArgs = Split(SuperTrim(Command$), " ")
'supertrim the command string before splitting it