Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2004, 12:48 AM
Registered User
 
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default parsing with double quotes

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
escape character for double quotes Andy dg C# 2005 3 March 15th, 2007 10:51 PM
double quotes MyronCope Classic ASP Basics 2 November 21st, 2006 09:31 AM
displaying single quotes and double quotes ren_123 Classic ASP Databases 2 February 22nd, 2006 02:17 PM
Double Quotes langer123 Classic ASP Basics 2 March 16th, 2005 06:22 PM
Double Quotes and Single Quotes Problem phungleon Classic ASP Basics 7 May 27th, 2004 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.