| start | [optional] (Integer) Numeric expression that sets the starting position for each search.
If not set, then search begins at the first character position. If the compare parameter is specified, then the start parameter is required. |
|---|---|
| string1 | (String) Text string being searched |
| string2 | (String) Text string searched for |
| compare | [optional] (Integer) Numeric value specifies the kind of comparison to use when evaluating substring.
If not set, then a binary comparison is performed. vbBinaryCompare - Perform a binary comparison
vbTextCompare - Perform a textual comparison |
Dim SearchString, SearchChar, nPos
SearchString = "XXpXXpXXPXXP"
SearchChar = "P"
nPos = InStr(4, SearchString, SearchChar, 1)
' A textual searching starting on the position 4, returns 6
nPos = InStr(1, SearchString, SearchChar, 0)
' a binary searching starting on the position 1, returns 9
nPos = InStr(SearchString, SearchChar)
' binary searching, returns 9
nPos = InStr(1, SearchString, SearchChar, "W")
' a binary searching from position 1, returns 0 ("W" is not found)