Name
InStr, InStrB Functions
Syntax
InStr([start, ]stringtosearch,stringtofind[,comparemode])
startUse: Optional
Data Type: Numeric
The starting position for the search.
stringtosearchUse: Required
Data Type: String
The string being searched.
stringtofindUse: Required
Data Type: String
The string being sought.
comparemodeUse: Optional
Data Type: Integer
The type of string comparison.
Return Value
A Long.
Description
Finds the starting position of one string within another.
Rules at a Glance
The return value of InStr is influenced by the values of
stringtosearchandstringtofind, as shown in the following table:
Condition | InStr return value |
| 0 |
| |
| |
| |
| 0 |
| Position at which the start of
|
| 0 |
If the
startargument is omitted, InStr commences the search with the first character ofstringtosearch.If the
startargument isNull, an error occurs.You must specify a
startargument if you are specifying acomparemodeargument.VBScript supports intrinsic constants for
comparemode, as follows:Comparison mode
Value
Constant
Binary (default)
0
vbBinaryCompareText—case- insensitive
1
vbTextCompareIn effect, a binary comparison means that the search for
stringtofindinstringtosearchis case-sensitive. A text comparison means that the search forstringtofindinstringtosearchis not case-sensitive. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access