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. 7 20685
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.
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.
Thank you very much. It worked :)
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
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
Hi Jay,
I never knew that this was possible.
Makes things again a lot easier.
:-)
Thanks
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: girish |
last post by:
In my XML document, some node attributes data contains both single quot
and double quote characters, such as
<input msg="Hello "World", What's up"/>.
The double quotes are in form of escape...
|
by: G. |
last post by:
This is an obvious bug in the String.Replace function:
//load a XML string into a document
XmlDocument doc = new XmlDocument();
doc.LoadXml("<test id='' />");
//Obtain the string...
|
by: Neo Geshel |
last post by:
Greetings
I am using VB in my ASP.NET project that uses an admin web site to
populate a database that provides content for a front end web site. I am
looking for a way to use replace() to...
|
by: Kevin Thomas |
last post by:
Hi there,
If I have a string var, strFoo that contains double-quotes such that it
looks like this: I "love" VB
What do I pass into the "replace" method to replace the double-quotes with...
|
by: AZNewsh |
last post by:
I am storing HTML in an oracle database, this is loaded from a textbox
in a webpage, I convert ' to ' ' using the code below:
foo.Replace("'", "''").Replace("&", "'||'&'||'")
this works just...
|
by: Eric Layman |
last post by:
Hi,
I've saved data into the db by doing a replace() on single quote.
Right now on data display on a datagrid, it shows double single quote.
How do I make changes during run time of datagrid...
|
by: bill |
last post by:
I am trying to write clean code but keep having trouble deciding
when to quote an array index and when not to.
sometimes when I quote an array index inside of double quotes I
get an error about...
|
by: dkirkdrei |
last post by:
I am having a bit of trouble trying to double up on slashes in a file
path. What I am trying to do is very similar to the code below:
<?
$var =...
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello,
I have some XML that is returned to my application from another vendor that
I cannot change before it gets to me. I can only alter it after it gets to my
application. That being said, I...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |