Version: 1.0
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.
Comparison Constants
CONSTANT | VALUE | DESCRIPTION |
---|---|---|
VBBINARYCOMPARE | 0 | Binary comparison (case sensitive) |
VBTEXTCOMPARE | 1 | Text Comparison (case insensitive) |
VBDATABASECOMPARE | 2 | Compare information inside database |
<% =InStr("ABCDE ABCDE", "C") %>
3
<% =InStr(4, "ABCDE ABCDE", "C")
%>
9
<% =InStr(1, "ABCDE ABCDE", "c", 0) %>
0
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.
<% =InStr(1, "ABCDE ABCDE", "c", VBTextCompare) %>
3
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.