Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: How to find a string with quotes in it using Instr()


Message #1 by "nick" <nick@i...> on Wed, 12 Sep 2001 09:34:53
Hi,



I have an xml document that i want to be able to search using the Inst() 

function.



The string i want to find is 

<sign value="Libra">



or 



<sign value="Leo">



i.e.



BeginPosition = Instr(strStars, "<sign value="Libra">")



But putting the quote marks in the string will surely mess this up.



How can i search for this without using the quote marks? Is there an ASCII 

character that i can substitute in and does Instr allow you to do this?



thanks in advance,



Nick
Message #2 by Kyle Burns <kburns@c...> on Wed, 12 Sep 2001 08:24:19 -0500
You can either use the ASCII value Chr(34) or double up your quotes ("") to

achieve this.  I will demonstrate both techniques, but I find code

implementing the double quotes difficult to follow when debugging.



'Method 1

Dim vbQuote

vbQuote



BeginPosition = Instr(strStars, "<sign value=" & vbQuote & "Libra" & vbQuote

& ">")





'Method 2

BeginPosition = Instr(strStars, "<sign value=""Libra"">"





If you're parsing a valid XML document, you may want to consider taking the

time to learn the XML document library.



=================================

Kyle M. Burns, MCSD

ECommerce Technology Manager

Centra Credit Union

kburns@c...



 



-----Original Message-----

From: nick [mailto:nick@i...]

Sent: Wednesday, September 12, 2001 4:35 AM

To: ASP Web HowTo

Subject: [asp_web_howto] How to find a string with quotes in it using

Instr()





Hi,



I have an xml document that i want to be able to search using the Inst() 

function.



The string i want to find is 

<sign value="Libra">



or 



<sign value="Leo">



i.e.



BeginPosition = Instr(strStars, "<sign value="Libra">")



But putting the quote marks in the string will surely mess this up.



How can i search for this without using the quote marks? Is there an ASCII 

character that i can substitute in and does Instr allow you to do this?



thanks in advance,



Nick

  Return to Index