Using Instr to find double quotes

OK, I'm sure I''m going to see the code and say 'DUH', but I can't figure it out.  I need to check a string for double-quotes, and then replace them with single quotes or display a message telling the user to change it themselves.  I want to write the following to identify the double-quotes, but I know it's not right...

   if Instr(1, stringX, """, 1) = true then

How can I check for the double-quotes?

Thanks in advance
Who is Participating?
stringX = Replace(stringX, """", "'")
...will replace them.  If you want ocheck, do this:

If Instr(stringX, """") > 0 Then
    'do something
End If
the problem with your code kcleary is that to get a double quote in VBScript (or VB for that matter) you have to put two double quotes in a row inside your string.

you were trying three double quotes, but that will probably just give you an 'unterminated string' error, because it sees you open one string, close the string, and then open another string. (or not close the first one)

if you want only a double quote you need to put four double quotes  """" instead of """

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

easier yet -

If Instr(stringX, chr(34)) > 0 Then
   'do something
End If
The only way to check it is

Dim strurl
strurl = "a""b"
strurl = replace(strurl,"",chr(34))
Response.Write strurl & "<br>"
Response.Write instr(1,strurl,chr(34))
kclearyAuthor Commented:
Thanks drittich, works great.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.