Syntax |
InStr([start,] search, find [,compare]) InStrB([start,] search, find [,compare]) |
||
Description |
Returns the first character position of string find within string search. |
||
Comments |
The InStr function takes the following parameters: |
||
|
Parameter |
Description |
|
|
start |
Integer specifying the character position where searching begins. The start parameter must be between 1 and 32767. If this parameter is omitted, then the search starts at the beginning (start = 1). |
|
|
search |
Text to search. This can be any expression convertible to a String. |
|
|
find |
Text for which to search. This can be any expression convertible to a String. |
|
|
compare |
Integer controlling how string comparisons are performed: |
|
|
|
0 |
String comparisons are case-sensitive. |
|
|
1 |
String comparisons are case-insensitive. |
|
|
Any other value |
A runtime error is produced. |
|
|
If this parameter is omitted, then string comparisons use the current Option Compare setting. If no Option Compare statement has been encountered, then Binary is used (i.e., string comparisons are case-sensitive). |
|
|
If the string is found, then its character position within search is returned, with 1 being the character position of the first character. |
||
|
The InStr and InStrB functions observe the following additional rules:
|
||
|
The InStr and InStrB functions operate on character and byte data respectively. The Instr function interprets the start parameter as a character, performs a textual comparisons, and returns a character position. The InStrB function, on the other hand, interprets the start parameter as a byte position, performs binary comparisons, and returns a byte position. On SBCS platforms, the InStr and InStrB functions are identical. |
||
Example |
This example checks to see whether one string is in another and, if it is, then it copies the string to a variable and displays the result. |
||
|
Sub Main() |
||
See Also |
Mid, Mid$ (functions); Option Compare (statement); Item$ (function); Word$ (function); Line$ (function). |
||
|
|
|
|
I |