469,631 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Replace " character in string

Can anyone help me, I'm trying to replace any double quotes in a
textbox with a different character.

mystring = Replace(TextBox.Text , " , "*")

I've tried chr(34) and """"" with no luck.

Thanks
Pete

Nov 19 '06 #1
5 2238

"xla76" <pe*********@gmail.comschreef in bericht
news:11**********************@j44g2000cwa.googlegr oups.com...
Can anyone help me, I'm trying to replace any double quotes in a
textbox with a different character.

mystring = Replace(TextBox.Text , " , "*")

I've tried chr(34) and """"" with no luck.

Thanks
Pete
Strange, something like:

TextBox1.Text = "Try to replace "" by #"

TextBox2.Text = Replace(TextBox1.Text, Chr(34), "#")

works without problems for me.

Groeten,

Jaap


Nov 19 '06 #2
Thanks Jaap,

nothing like a simple typo to throw a spanner in the works - but at
least you confirmed for me that it should work.

Nov 19 '06 #3
"xla76" <pe*********@gmail.comschrieb:
Can anyone help me, I'm trying to replace any double quotes in a
textbox with a different character.

mystring = Replace(TextBox.Text , " , "*")

I've tried chr(34) and """"" with no luck.
Use 'ControlChars.Quote' or '""""' (a string literal containing a single
double quote character, which is escaped by placing two consecutive double
quote characters inside the VB string literal).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 19 '06 #4

"xla76" <pe*********@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
Can anyone help me, I'm trying to replace any double quotes in a
textbox with a different character.

mystring = Replace(TextBox.Text , " , "*")

I've tried chr(34) and """"" with no luck.

Thanks
Pete
This works fine for me in the context of a Windows application:

Dim vale As String

vale = Replace(Textbox.Text, """", "*")

Textbox.Text = vale

If it fails for you, perhaps you could supply details such as application
type and template you're using?


Nov 19 '06 #5
guy
I always use (or a constant derived from it) ControlChars.Quote
as it reads so much clearer

guy

"xla76" wrote:
Can anyone help me, I'm trying to replace any double quotes in a
textbox with a different character.

mystring = Replace(TextBox.Text , " , "*")

I've tried chr(34) and """"" with no luck.

Thanks
Pete

Nov 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Terry Olson | last post: by
14 posts views Thread by Etu | last post: by
6 posts views Thread by Dean Slindee | last post: by
4 posts views Thread by Kevin Thomas | last post: by
8 posts views Thread by Lothar Behrens | last post: by
6 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.