Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing double quotes

Status
Not open for further replies.

compcad

Programmer
Mar 22, 2002
52
0
0
US
My client has a program that has arguments with double quotes around them and then he has code that is to be used to pass the arguments with double quotes to the back end i developed here is that code:

Sub ParseCommandLine(CmdLine, RaffleID, Password, FirstTicketNo, LastTicketNo)
' There will be either 3 or 4 parameters
' If there are only 3 then the third is last ticket no and a first ticket no of 1 is implied
' If there are 4 then the third is first ticket no and the fourth is last ticket no
' The first 2 args are always password and RaffleID

Password = GetNextArgument(CmdLine)
RaffleID = GetNextArgument(CmdLine)
FirstTicketNo = GetNextArgument(CmdLine)
LastTicketNo = GetNextArgument(CmdLine)

If LastTicketNo = "" Then
LastTicketNo = FirstTicketNo
FirstTicketNo = 1
End If

End Sub
Function GetNextArgument(CmdLine)

Index = InStr(CmdLine, " ")
If (Index = 0) Then
'End of line
GetNextArgument = CmdLine
GetNextArgument = Replace(CmdLine, """", "")
'Remove double quotes
CmdLine = ""
Exit Function
End If
GetNextArgument = Left(CmdLine, Index)
GetNextArgument = Replace(GetNextArgument, """", "") 'Remove double quotes
CmdLine = Right(CmdLine, Len(CmdLine) - Index)
End Function

Private Sub Command1_Click()
Call ParseCommandLine(CmdLine, RaffleID, Password, FirstTicketNo, LastTicketNo)
Dim cCommand As String
cCommand = "C:\Program Files\RaffleMaker\RMDESKTOP\TB - LITE.EXE " & _
CmdLine & ", " & RaffleID & ", " & Password & ", " & FirstTicketNo & ", " & LastTicketNo
RetVal = Shell(cCommand, 1)
End Sub

is what i am wanting to know am i going to need to have double quotes in my back end if so how would i set that up here is the code in my program that deals with parsing is below:

Dim strValuesFromCommandLine() As String

Dim CmdLine As String
Dim RAFFLEID As String
Dim PASSWORD As String
Dim FirstTicketNo As String
Dim LastTicketNo As String
Dim RAFFLEID1a As String

Form1.WindowState = 0

If Len(Command) > 0 Then
strValuesFromCommandLine() = Split(Command$, ", ")
CmdLine = strValuesFromCommandLine(0)
RAFFLEID = strValuesFromCommandLine(1)
PASSWORD = strValuesFromCommandLine(2)
FirstTicketNo = strValuesFromCommandLine(3)
LastTicketNo = strValuesFromCommandLine(4)
Else
MsgBox "Stand alone is not supported by this program.", vbOKOnly
End
End If
 
No you don't need them. See also thread222-818830

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top