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
kclearyAsked:
Who is Participating?
 
drittichConnect With a Mentor Commented:
stringX = Replace(stringX, """", "'")
0
 
drittichCommented:
...will replace them.  If you want ocheck, do this:

If Instr(stringX, """") > 0 Then
    'do something
End If
0
 
ebosscherCommented:
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 """

cheers
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
funkeCommented:
easier yet -

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

T.P.
<%
Dim strurl
strurl = "a""b"
strurl = replace(strurl,"",chr(34))
Response.Write strurl & "<br>"
Response.Write instr(1,strurl,chr(34))
%>
0
 
kclearyAuthor Commented:
Thanks drittich, works great.
0
All Courses

From novice to tech pro — start learning today.