Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to look for double quote (") 1

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
I need to search a string for double quotes ("). I don't know how to write the double quote without getting an error.

I tried """ using the instr function and I got a debug error saying I am missing a double quote. I also tried using an "if then" statement

if string like "*"*" then
msgbox "don't use doulbe quotes."
end if

but I get the same error. Is it possible to search for " in a string? Thank you for your assistance

Jason Meckley
Database Analyst
WITF
 
SELECT * FROM myTable WHERE fieldName LIKE "*""*" Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Hi Jason!

Since the error message said you were missing a double quote did you try:

"""" in the InStr function or

if string like "*""*" then
msgbox "don't use doulbe quotes."
end if

To see if either one works that way?

hth
Jeff Bridgham
bridgham@purdue.edu
 
if string like "*"+chr(34)+"*" then
msgbox "don't use doulbe quotes."
end if
 
how about using:
Code:
if instr(1,string,"""") > 0 then
    msgbox "don't use double quotes"
end if
or you can put in a constant (I ususally do this) like:

Const DBLQUOTE as String = """"

Then you can do this:
Code:
if instr(1,string,DLBQUOTE) > 0 then
    msgbox "don't use double quotes"
end if

let me know if this helps!

GComyn
 
After sleeping on it, I had a thought....

If you have an input form, you can do the following in any (or all) of the fields that the user enters text information:

[using the field txtNotes as an example]
Code:
function txtNotes_AFterUpdate()
    dim strTemp as String
    dim intPos as Integer

    strTemp = me.txtnotes.value
    intpos = instr(1,strtemp,"""")
    do while intpos > 0
        strtemp = left(strtemp,intpos-1)
        strtemp = strtemp & mid(strtemp,intpos+1)
        intpos = instr(1,strtemp,"""")
    loop
    me.txtnotes.value = strtemp
end function

That way, when they enter the text, it automatically strips the double quotes from it before continuing on to the next field.

let me know if this is any help.....

GComyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top