Results 1 to 7 of 7

Thread: Replace double quotes (") with single quotes (')

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    30

    Replace double quotes (") with single quotes (')

    Hi,

    I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code:

    text= Replace(text, """", "'")

    This works fine (for normal double quotes).The problem comes in when you copy a double quote from word and paste it in the text box. What happens is the double quote becomes slanted (“) so my code above can't filter it. I tried to do this:

    text= Replace(text, "““","'")

    but what happens is that after typing this, vb automatically converts it to the normal double quote ("). I already tried:

    text= Replace(text, chr(34), "'") ' 34 is the ascii of double quotes (")

    but still, it won't work. I can't seem to find the ascii of the slanted double quotes, they somehow look all the same to me

    Is there a work around for this?

    Thanks.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    You could use Regular Expressions for this (especially if you are running many different types of text replacement operations).

    Be warned though, once you start, you'll be addicted for life.

    Look up Regex in MSDN for more info.

    or you could just use:

    asc("“")

    to find out the ascii value

    Regex is dead powerful though and you should learn it. IMHO
    I don't live here any more.

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    If the text is unicode formatted then there might be further complications. VB6 had StrConv() to sort that out, I don't know what the .net equiv would be.
    I don't live here any more.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    30
    > asc("““")


    once you type this in .net, it will automatically convert it to this right after typing it:

    asc("""")

    (you may try this if you want --> type a double quote in word then copy and paste it to the vb.net editor)

    In effect, this will just give you the ascii for " which is 34.


  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    What about the VB6 immediate window? That should work.

    ?asc("““")
    I don't live here any more.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    30
    what's a vb6 immediate window? im working on vb.net. forgive my ignorance on the terms, im kinda new to this

  7. #7
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    he must mean the vb6.net version lol just kidding (couldn't resist)

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