Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 636
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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