Solved

Replace characters from string

Posted on 2009-06-30
5
589 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
Comment Utility
Try this:
chr(34) = "
chr(39) = '
MyComments = Request.Form("comments")
MyComments = Replace(MyComments ,chr(34),chr(39))
0
 

Author Comment

by:sanjshah12
Comment Utility
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
Comment Utility
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
Comment Utility
Cool thanks - apologies about the comment - it was me being daft! thanks again!
0
 
LVL 67

Expert Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now