Home |
About me |
EXCEL
VB Programming (XL97-2003) |
ACCESS Programming |
EXCEL VB.Net Programming |
EXCEL Spreadsheet Functions |
Material Management |
Guestbook
|
InStr Function
Returns a Variant (Long) specifying the position of the first occurrence of one string within another.
Syntax
InStr([start, ]SourceString, SearchString[, compare])
The InStr function syntax has these arguments:
Part |
Description |
start | Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified. |
SourceString | Required. String expression being searched. |
SearchString | Required. String expression sought. |
compare | Optional. Specifies the type of string comparison. If compare is Null, an error occurs. If compare is omitted, the Option Compare setting determines the type of comparison. |
Settings
The compare argument settings are:
Constant |
Value |
Description |
vbUseCompareOption | -1 | Performs a comparison using the setting of the Option Compare statement. |
vbBinaryCompare | 0 | Performs a binary comparison. |
vbTextCompare | 1 | Performs a textual comparison. |
vbDatabaseCompare | 2 | Microsoft Access only. Performs a comparison based on information in your database. |
Return Values
If |
InStr returns |
SourceString is zero-length | 0 |
SourceString is Null | Null |
SearchString is zero-length | start |
SearchString is Null | Null |
SearchString is not found | 0 |
SearchString is found within SourceString | Position at which match is found |
start > SearchString | 0 |