borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (what is intstatus for?) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Replacing the " character within a string
Poster Message
iliekater
Level: Master

Registered: 04-02-2005
Posts: 134

icon Replacing the " character within a string

Here's a funny problem :
I have a text box in which the user can write a text . However in that text , the user may contain the " caracter . This may casue problems within the VB code when trying to retrive the text from the text box :
MyString = MyTextBox.Text
Therefore I'd like to replace the " character with two single lines :  '  .
How can I do that ? Using the following code returns an error :
Replace(MyTextBox.Text , """ , "''")
(at the last part I used two single ' characters)

[Edited by iliekater on 15-08-2008 at 11:04 AM GMT]

15-08-2008 at 07:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 543
icon Re: Replacing the " character within a string

Try this :-
Replace(MyTextBox, Chr(34), Chr(39))


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

01-09-2008 at 03:44 PM
View Profile Send Email to User Show All Posts | Quote Reply
AlanCF
Level: Trainee

Registered: 12-10-2008
Posts: 1
icon Re: Replacing the " character within a string

You can also use Replace(MyTextBox.Text , """" , "''")
notice """", put two double-quotes inside double-quotes to represent one double-quote.

12-10-2008 at 07:55 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Replacing the " character within a string
Next Topic (what is intstatus for?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder