FUNCTION: InStr( )
Implemented in version 1.0
InStr(Start,
String, Substring, Compare)
The InStr function returns the numeric position of the first
occurrence of a specified substring within a specified string when starting
from the beginning (left end) of the string.
You can have the search for the substring be sensitive to the case (upper versus lower), or not.
The default is to be case sensitive (binary comparison).
An output of zero indicates no match.
The first argument is optional.
Start
The optional Start argument is the numeric position,
counted from the left, which defines where to start the search for the
substring. The search proceeds from the left to the right.
There are two mandatory arguments.
String
The String argument is the string in which you will search.
Substring
The Substring argument is the substring you are searching for.
Code:
<% =InStr("ABCDE ABCDE", "C")
%>
Output:
3
Code:
<% =InStr(4, "ABCDE ABCDE", "C")
%>
Output:
9
The fourth argument is optional.
Compare
The optional Compare argument can be used to set whether the search for the
substring will be case sensitive, or not.
You must only use either the constant
or value of the COMPARISON CONSTANTS.
Note that when you use the Compare argument you must use the Start
argument.
| CONSTANT |
VALUE |
DESCRIPTION |
| VBBINARYCOMPARE |
0 |
Binary comparison
(case sensitive) |
| VBTEXTCOMPARE |
1 |
Text Comparison
(case insensitive) |
| VBDATEBASECOMPARE |
2 |
Compare information
inside database |
In the example, by using VBBinaryCompare, or 0, for the Compare
argument, all upper/lower case differences are obeyed in the search
for the first match.
Code:
<% =InStr(1, "ABCDE ABCDE", "c",
0) %>
Output:
0
In the example, by using VBTextCompare, or 1, for the Compare
argument, all upper/lower case differences are ignored in the search
for the first match.
Code:
<% =InStr(1, "ABCDE ABCDE", "c",
VBTextCompare) %>
Output:
3
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
|