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

Why does inStr only work every once-in-a while?

Status
Not open for further replies.

slavdaddy

Programmer
Sep 14, 2001
13
US
Howdy all. I have this problem, or really a performance boost issue, that I want to solve, but I can't get inStr to work.

I have a dynamic site engine that I wrote, and it works pretty well for the most part, but part of it allows for dynamic menu generation in several forms. Using images, tiered or not, horizontal or vertical, etc.

Now, it also uses template files, and each menu form has a sepcific custom tag. For instance,
Code:
<menu_v_t>
would be a tiered, vertical menu.

The problem is this: right now, since I can't get
Code:
inStr
to work correctly, I have to form all of those menus and try to replace them whether or not the tag is in the file (of coure it only replaces if it is in the file), and that means more effort than necessary for the server. What I would like to have happen is to say something like

Code:
If inStr(strPage, SomeCustomtag) Then
     formMenuForThatTag
End If


Unfortunately, that doesn't work. inStr doesn't return true even if the tag is in the file. Has anyone run into this? Please help.

Thanks,
Corey

PS - I tried both binary and textual comparison. Neither worked.
 
Hi

Instr returns a numerical value representing the position of the search string in the string that is being searched.

It will return 0 if it is not found and a positive number if it is found.

Hope that helps
Derren
[The only person in the world to like Word]
 
Thanks derren. I keep forgetting that -1 is true in vbScript. Man, I feel dumb. Why can't it all be like C [pipe]?

Thanks again.

-Corey
 
Nope, that wasn't even the case. Upon further examination, I found that I shouldn't code until the wee hours for several nights in a row. I did something even dumber than the -1 instead of 1 thing. It seems like vbScript interprets any non-zero number as true, like C. However, if you type in the wrong variable name, vbScript will apparently not figure out what you meant to type. [sadeyes] Woo. But I got it now, and boy do I feel silly. Thanks again, everyone.

-Corey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top