Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

.asp question if "contains"

Guest
Jul 10, 2006 Jul 10, 2006
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.
TOPICS
Server side applications
449
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2006 Jul 10, 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 %>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2006 Jul 10, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2006 Jul 10, 2006
Found it. Go to Microsoft and look for "Windows Script 5.6 Documentation" The file is called scipt56.chm.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 11, 2006 Jul 11, 2006
Thanks I will give it a try.

Hope this works with vb script.

I will let you know how it turns out.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 11, 2006 Jul 11, 2006
LATEST
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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines