Solved

Using Instr to find double quotes

Posted on 2002-07-15
6
2,058 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:kcleary
6 Comments
 
LVL 8

Accepted Solution

by:
drittich earned 75 total points
ID: 7154399
stringX = Replace(stringX, """", "'")
0
 
LVL 8

Expert Comment

by:drittich
ID: 7154402
...will replace them.  If you want ocheck, do this:

If Instr(stringX, """") > 0 Then
    'do something
End If
0
 
LVL 6

Expert Comment

by:ebosscher
ID: 7154425
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 5

Expert Comment

by:funke
ID: 7154492
easier yet -

If Instr(stringX, chr(34)) > 0 Then
   'do something
End If
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 7154497
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
 

Author Comment

by:kcleary
ID: 7154522
Thanks drittich, works great.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Auto Submit on dropdown box 14 72
Problems using Provider=OraOLEDB.Oracle via VBScript/Classic ASP 5 85
ASP server side get value 15 35
If condition on Html with Asp 11 27
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question