+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, Escape quotations in VBS in Coding and Web Development; Simple question - how do I escape " in a vbscript ? I want "this text echoed" including the "...
  1. #1


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Escape quotations in VBS

    Simple question - how do I escape " in a vbscript ?

    I want "this text echoed" including the "

  2. #2
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: Escape quotations in VBS

    Drives me insane. You usually dou double quotes sometimes triple or single quotes in double quotes. Show me what you want to do it with exactly and I can tell you.

  3. #3


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Escape quotations in VBS

    Thanks. double quoting did it

  4. #4
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: Escape quotations in VBS

    Good good. Check out this fun I had building the command line for a recent image coversion wrapper:

    Code:
    StrCMDLine = "c:\imagemagick\convert.exe " & """" & CombinedPath & """" & " " & """" & OutPath & """"

  5. #5

    Join Date
    Jan 2006
    Posts
    143
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Escape quotations in VBS

    Aaaarrggggh!! Escaping quotes in vbs is my arch-nemesis!! :twisted:

  6. #6
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    Re: Escape quotations in VBS

    If you are starting to lose track of things, then you can always use chr(34)
    Code:
    MyCmdLine = "App.exe " & chr(34) & "C:\Path with spaces\file.dat" & chr(34)
    Sometimes it's easier that way.

    The other thing I do is to create an Enqote function
    Code:
    function Enquote(sSource)
      Enquote = chr(34) & sSource & chr(34)
    end function
    Then you can do
    Code:
    MyCmdLine = "App.exe " & Enquote("C:\Path with spaces\file.dat")

  7. #7

    Join Date
    Jan 2006
    Posts
    143
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Escape quotations in VBS

    Quote Originally Posted by ajbritton
    If you are starting to lose track of things, then you can always use chr(34)
    Code:
    MyCmdLine = "App.exe " & chr(34) & "C:\Path with spaces\file.dat" & chr(34)
    Sometimes it's easier that way.

    The other thing I do is to create an Enqote function
    Code:
    function Enquote(sSource)
      Enquote = chr(34) & sSource & chr(34)
    end function
    Then you can do
    Code:
    MyCmdLine = "App.exe " & Enquote("C:\Path with spaces\file.dat")
    That's a nice approach. Thanks

  8. #8
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    Re: Escape quotations in VBS

    Just thought of another way...
    Code:
    MyCmdLine = Replace("$$C:\Path with spaces\file.dat$$", "$$", chr(34))

SHARE:
+ Post New Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •