Solved

Replace characters from string

Posted on 2009-06-30
5
608 Views
Last Modified: 2012-05-07
Hi,
I'm rying to replace some special characters from a string before submittng to a DB, in particualr the ", I know I can use the replace command but cannot get this working for " with '

      MyComments = Request.Form("comments")
      MyComments = Replace(MyComments ,"""","'")
0
Comment
Question by:sanjshah12
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 24744962
Try this:
chr(34) = "
chr(39) = '
MyComments = Request.Form("comments")
MyComments = Replace(MyComments ,chr(34),chr(39))
0
 

Author Comment

by:sanjshah12
ID: 24745020
Thanks for the reply, I get an error with the script

Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/AddComments.asp, line 39
chr(34) = "
-----------^

0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 24745036
Sorry those were comments...just the last two lines:
MyComments = Request.Form("comments")
MyComments = Replace(MyComments ,chr(34),chr(39))

Open in new window

0
 

Author Comment

by:sanjshah12
ID: 24745099
Cool thanks - apologies about the comment - it was me being daft! thanks again!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24745106
No worries - glad I could help.  Thanx for the grade! :^)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question