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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for " using Instr

Status
Not open for further replies.

annandap

IS-IT--Management
Dec 9, 2001
11
AU
Hi,
I am trying to search for " in a string using the Instr function. When using the following syntax it returns an error stating that I neeed to have double quotes..

myCount = instr(mystring, """)

Any help would be greatly appreciated
 
i always get really confused with these sorts of "'" and wotnot. i tend to go for Chr(34) instead

try it, it might work
 
msgbox """"
'that displays a "
'dont ask me how, perhaps if you put that in your instr
 
And what about this:
Code:
myCount = Instr(mystring, Chr(34))

Hope This Help
PH.
 
Thanks for that, I was doing some investigation into using CHR(34) but couldn't find any reference on the internet for ANSI/ASCII codes.

Anyway I tried both methods """" and CHR(34) and both worked perfectly.

Thanks for all your assistance..

Regards..

Peter
 
Explanation: to escape a " just double it up as ""
Example:
[tt]myString = "This string has a "" in it"[/tt]
[tt] ^ appears as one " in the string[/tt]
So in your instr():
[tt]InStr(mystring, """")[/tt]
" " : start string & end string quotes
" : escape next quote
" : actual quote char :)

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top