• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 638
  • Last Modified:

Replace characters from string

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
sanjshah12
Asked:
sanjshah12
  • 3
  • 2
1 Solution
 
sirbountyCommented:
Try this:
chr(34) = "
chr(39) = '
MyComments = Request.Form("comments")
MyComments = Replace(MyComments ,chr(34),chr(39))
0
 
sanjshah12Author Commented:
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
 
sirbountyCommented:
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
 
sanjshah12Author Commented:
Cool thanks - apologies about the comment - it was me being daft! thanks again!
0
 
sirbountyCommented:
No worries - glad I could help.  Thanx for the grade! :^)
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now