Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 18th, 2003, 02:53 PM
Authorized User
Join Date: Aug 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default help on functions instr....

I am writing a function to keep the values between the content class when i search an html page because I just want the text between the content class to be searched, but it keep giving me errors.

iPos = InStr(1,orig_string,"<p class=""content"">")

Function Remove(orig_string)
iPos = InStr(1,orig_string,"<p class=""content"">")
If iPos = 0 then
strTitle = "Untitled"
strTitle = Mid(orig_string,iPos+21,InStr(iPos,orig_string,"<p class=""content"">")-iPos-21)
End If
End Function

    contValue = "<p class=""content"">Monsignor Frank Rossi - Director<p class="content">"
x= remove(contValue)
response.write x

Old September 19th, 2003, 02:56 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

I can see a few things here:
1. in your test string (contValue=...) you haven't doubled up the quotes around the ending "content"
2. in this line: strTitle = Mid(orig_string,iPos+21,InStr(iPos,orig_string,"<p class=""content"">")-iPos-21) you need to start the InStr at iPos+1 not at iPos
3. your iPos+21 and iPos-21 should be iPos+19 and iPos-19 because the double quotes don't actually exist in the string variable orig_string

I'm confused about one thing though, in that line contValue = "<p class=""content"">Monsignor Frank Rossi - Director<p class="content">" , shouldn't the ending tag be just </p>? Or is it the starting tag for another para element?

Old September 19th, 2003, 10:01 AM
Authorized User
Join Date: Aug 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts

actually i fixed my script and ipos is 21 =). Weird but it works....thanks.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Oracle Instr ermutigen BOOK: SQL Functions Programmer's Reference 1 May 31st, 2009 12:04 AM
InStr() repeat instances spinout Classic ASP Components 7 November 23rd, 2006 11:55 AM
CHARINDEX instead of Instr... mircea Classic ASP Databases 7 July 19th, 2004 01:47 PM
instr function Beulah ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2003 01:54 AM
InStr() in Access 2000 fordrs3 Access VBA 1 July 8th, 2003 05:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.