Results 1 to 10 of 10

Thread: Putting a string within quotations

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    I have the following code, but am unable to figure out how to put my appropriate strings within the quotations effectively.

    Code:
    Private Sub cmdSend_Click()
    
    With Inet1
            .Protocol = icFTP
            .URL = "xxx.xxx.xxx.xxx"
            .UserName = "xxx"
            .Password = "xxx"
            .Execute , "PUT C:\Program Files\Test.txt Test.txt"
        End With
    
    End Sub
    I want to put string variables in the place of the directory path listed. How can I do this and still get the execute command to work?
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  2. #2
    Guest
    Use triple quotes to enclose it in quotes.
    Code:
    """PUT C:\Program Files\Test.txt Test.txt"""

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    I mean I want to replace the C:\Program Files\Test.txt with something like Text1.txt, so this would require a string within the quotations it would appear, in order for the .Execute to run correctly.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'it's as Megatron says
    
    Dim helpme As String
    helpme = """PUT C:\Program Files\Test\Test.txt Text.txt"""
    'for display
    MsgBox helpme
    
    example:
    .Execute , helpme
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    Maybe it will help clarify here if I show you exactly what I want to do.

    Code:
    Private Sub cmdSend_Click()
    
    Dim strFileName As String, strFileTitle As String
    strFileName = "C:\Program Files\Test.txt
    strFileTitle = "Test.txt"
    
    With Inet1
            .Protocol = icFTP
            .URL = "xxx.xxx.xxx.xxx"
            .UserName = "xxx"
            .Password = "xxx"
            .Execute , "PUT ""strFileName""strFileTitle"
        End With
    
    End Sub
    I appreciate your helping, and hope this clarifys the conflict.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  6. #6
    Guest
    How about:
    Code:
    "PUT " & strFileName & " " & strFileTitle

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    That renders the following text line:

    "PUT " C:\Test.txt Test.txt

    It has to look like "PUT C:\Test.txt Test.txt" ultimately.

    Thanks for helping me brainstorm this. I had thought that strings that would be inserted inside operational statements would be a cakewalk, but this one is a monster to figure out.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316
    In fact to be quite honest, if I need the dir path to be separated text such as C:\Program Files\Test.txt then the operational statement must ultimately look like this...

    Code:
    .Execute , "PUT ""C:\Program Files\Test.txt""Test.txt"
    That Operational line works like a charm every time. But I am not understanding how to do the same operational line by using string variables instead of the actual Names.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  9. #9
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Try putting triple quotes around everything.

    Option Explicit
    Dim strOne As String
    Dim strTwo As String
    Dim strResult As String

    Private Sub Command1_Click()
    strOne = "string 1"
    strTwo = "string 2"
    strResult = """PUT """ & """strone""" & " " & """strtwo"""
    MsgBox strResult
    End Sub

    strResult will contain "PUT ""strone" "strtwo"

  10. #10
    New Member
    Join Date
    Aug 2000
    Posts
    11
    Try:

    have a temporary string

    strTemp = "PUT " & strFileName & " " & strFileTitle

    .execute , strTemp

    or failing that try:

    strTemp = """ & "PUT " & strFileName & " " & strFileTitle & """

    It wins awards for ludicrousy but it might just work...


    Give me five lines written by the most honourable of men, and I shall find in them an excuse to hang him. - Cardinal Richelieu

    Ben Stappleton
    VB6E SP4

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