Replace " character in string

  • Thread starter Thread starter xla76
  • Start date Start date
X

xla76

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
 
xla76 said:
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
 
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.
 
xla76 said:
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).
 
xla76 said:
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?
 
I always use (or a constant derived from it) ControlChars.Quote
as it reads so much clearer

guy
 
Back
Top