Skip to main content
July 11, 2006
Question

.asp question if "contains"

  • July 11, 2006
  • 5 replies
  • 448 views
I have been stuck on this fo a bit. It is an .asp question.

<% if "john123" contains "john" then %> I am john <% end if %>

So what is the symbol for "contains" ? or how is this done?

Thank you for any help.
This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

July 11, 2006
OK. This Works! I just for got to put the "then" part of the statment.

<% if inStr("john123", "john") > 0 %> I am john <% end if %>
to
<% if inStr("john123", "john") > 0 then %> I am john <% end if %>

COOL. I am reading the docs now!
Participating Frequently
July 11, 2006
Found it. Go to Microsoft and look for "Windows Script 5.6 Documentation" The file is called scipt56.chm.
July 11, 2006
Thanks I will give it a try.

Hope this works with vb script.

I will let you know how it turns out.
Participating Frequently
July 11, 2006
Now that I'm looking at it, the StrComp (string comparison) function works similarly, but it returns a -1, 0 of 1. It's either in the string or not.

BTW: Try to find the Windows Script Technology help file at Microsoft. I forget where or how I got it. It might have come with Access. It's invaluable for finding this type of stuff. ASP is partly VBScript, and the help file has a lot of info for that part of ASP.

Again, I don't remember where I got it, but the title bar for the help file says Window Script Technology.
Participating Frequently
July 11, 2006
I've used the inStr function. If in string1 it finds string2, it returns the position in string1 where string2 was found. If it returns anything greater than 0, it found it.

<% if inStr("john123", "john") > 0 %> I am john <% end if %>