n = InstrRev(string1, string2[, start[, compare]])
string1 | (String) Text string being searched |
---|---|
string2 | (String) Text string searched for |
start | [optional] (Integer) Numeric expression that sets the starting position for each search. If not set, then -1 is used (it means that the search begins at the last character position). |
compare | [optional] (Integer) Numeric value indicating the kind of comparison to use when evaluating substrings. 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 = InstrRev(SearchString, SearchChar, 10, 0) 'a binary comparison starting at position 10, returns 9
nPos = InstrRev(SearchString, SearchChar, -1, 1) 'a textual comparison starting at the last position, returns 12
nPos = InstrRev(SearchString, SearchChar, 8) 'a binary comparison, returns 0