By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

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

P: n/a
gar
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 MS 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 in visual studio, 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.
Nov 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Gar,
I can't seem to find the ascii of the slanted double quotes,
they somehow look all the same to me There is no ASCII for a Double Quote, there is an ANSI for Double Quote,
however I would recommend Unicode instead, so as to avoid
internationalization issues (read different ANSI code pages). You can use
Character Map under "Start - Programs - Accessories - System Tools" to find
the Unicode code point for the different typographic quote chars available.

Try something like:

' what most people think of quote chars
Const Apostrophe As Char = ChrW(&H27) ' single quotes
Const Quote As Char = ChrW(&H22) ' double quotes

' various typographic quote characters
Const LeftSingleQuote As Char = ChrW(&H2018)
Const RightSingleQuote As Char = ChrW(&H2019)
Const LeftDoubleQuote As Char = ChrW(&H201C)
Const RightDoubleQuote As Char = ChrW(&H201D)

' other typographic quote characters (international)
' Note: HP48 uses these for delimiters
Const LeftPointingDoubleAngleQuote As Char = ChrW(&HAB)
Const RightPointingDoubleAngleQuote As Char = ChrW(&HBB)

' other typographic quote characters (international)
Const SingleLow9Quote As Char = ChrW(&H201A)
Const SingleHighReversed9Quote As Char = ChrW(&H201B)
Const DoubleLow9Quote As Char = ChrW(&H201E)

' simulate cut & paste from Word
Dim text As String = LeftDoubleQuote & "This is a test" &
RightDoubleQuote

text = text.Replace(LeftDoubleQuote, Apostrophe)
text = text.Replace(RightDoubleQuote, Apostrophe)

Note I included most of the various typographic quote characters. The four
that are commonly used by Word (in the US) are LeftSingleQuote,
RightSingleQuote, LeftDoubleQuote and RightDoubleQuote.

For details on quote chars & typographic quote chars see:
http://www.amazon.com/exec/obidos/tg...67152?v=glance

Hope this helps
Jay
"gar" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com... 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 MS 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 in visual studio, 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.

Nov 20 '05 #2

P: n/a
Gar,
I should add that there is no ASCII Left Double Quote, as ASCII is a 7 bit
code point (chars 0 to 127), while ANSI is 8 bit code point (chars 0 to
255). Where chars 0 to 127 are the same as ASCII, while chars 128 to 255
vary depending on local.

Unicode allows for millions of code points, so the need for code pages found
in ANSI is eliminated...

Also: Chr & Asc deals with ANSI code points, while ChrW & AscW deals with
Unicode code points.

Hope this helps
Jay

"gar" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
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 MS 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 in visual studio, 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.

Nov 20 '05 #3

P: n/a
gar
Thank you very much. It worked :)
Nov 20 '05 #4

P: n/a
Hi Jay,

Will you point me for a good link for those Unicodes, I see you have them
mostly all or is it from a book?

Cor
Nov 20 '05 #5

P: n/a
Cor,

Will any of these help?

http://www.nefec.org/UPM/sansi.htm
http://www.unicode.org/charts/
http://www.jpsoft.com/help/index.htm?codesref.htm

Thanks
MCN

"gar" <an*******@discussions.microsoft.com> wrote in message
news:71**********************************@microsof t.com...
Thank you very much. It worked :)

Nov 20 '05 #6

P: n/a
Cor,
I used Character Map & looked for them.

Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
Hi Jay,

Will you point me for a good link for those Unicodes, I see you have them
mostly all or is it from a book?

Cor

Nov 20 '05 #7

P: n/a
Hi Jay,

I never knew that this was possible.
Makes things again a lot easier.

:-)

Thanks

Cor
Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.