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

Replace " character in string

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a

"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

P: n/a
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

P: n/a
"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

P: n/a

"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

P: n/a
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.