SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Visual Basic - escaping double quotes

    I'm trying to replace a string of html in a csv file that contains double quotes, and I thought this was right:

    Code:
    txtLine = Replace(txtLine, "<a href=""http://wireless.fcc.gov/services/personal/generalmobile/"" target=""_blank"">www.fcc.gov</a>.", "")
    But apparently not because it's not replacing it...am I not escaping the quotes correctly?
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    That bit of code works just fine for me.

  3. #3
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I'm totally stumped...I also tried:

    Code:
    txtLine = Replace(txtLine, "<a href=" & Chr(34) & "http://wireless.fcc.gov/services/personal/generalmobile/" & Chr(34) & "target=" & Chr(34) & "_blank" & Chr(34) & ">www.fcc.gov</a>.", "")
    but still nothing...
    Quote Originally Posted by vgarcia
    That bit of code works just fine for me.
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know about VB, but in PHP if you want to use double quotes inside a text string you have to add an escape character ( \ ) before the double quote. So it would be like this:
    a = "<a href=\"http://wireless.fcc.gov/services/personal/generalmobile/\" target=\"_blank\">www.fcc.gov</a>\""

  5. #5
    Non-Member bronze trophy geniusgoalie's Avatar
    Join Date
    Sep 2004
    Location
    Buffalo, USA
    Posts
    979
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    That bit of code works just fine for me.
    same with me
    What version vb are you using?

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    USA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jim,

    I tried the following in VB:

    txtline = "Hi Jim <a href=""http://wireless.fcc.gov/services/personal/generalmobile/"" target=""_blank"">www.fcc.gov</a>."

    txtline = Replace(txtline, "<a href=""http://wireless.fcc.gov/services/personal/generalmobile/"" target=""_blank"">www.fcc.gov</a>.", "")

    Debug.Print txtline

    I get "Hi Jim" so the replace works on mine!
    Have you tried replacing the quotes with CHR(34) ?


Bookmarks

Posting Permissions

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