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

Includes Conditional

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I know I can use INCLUDES in an SQL statement, but is there a non-SQL version that can function like it in a conventional VBScript conditional? That is, I want to have a condition that is met when only part of a string matches, like:

[tt]If session("Item1") includes "ABCD" Then . . .[/tt]

when session("Item1") is actually ABCDEFG

Is there such a thing? Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
Try the inStr() function, e.g.:
inStr(stringtosearch,stringtofind)

You example could read like this:
Code:
If inStr(session(&quot;Item1&quot;),&quot;ABCD&quot;)<>0 Then

The inStr() function returns an integer value representing the starting(character) position of one string (&quot;ABCD&quot;) in another (session(&quot;Item1&quot;)). As long as the value returned is not zero, then stringtofind was found in stringtosearch.
 
Thanks! That's exactly what I needed. Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top