Method: InStrRev for VBS
- Updated2024-09-12
- 2 minute(s) read
Methods > Method: InStrRev for VBS
Method: InStrRev for VBS
Specifies the position in the text where a character or a character string appears in the text for the first time, whereby the search begins at the end of the text.
vInStrRev = Object.InStrRev(string1, string2, [start], [compare])
Object | VBS Object with this method. You do not need to specify this object. | ||||||||||||||
string1 | Variant Specifies the text you want to search through. | ||||||||||||||
string2 | Variant Specifies the character string you want to search for. | ||||||||||||||
[start] | Variant Specifies the start position of the search. If you do not specify start, the InStrRev method uses the value -1, which indicates that the search begins with the last character. | ||||||||||||||
[compare] | Variant Specifies the type of comparison. Possible settings are vbBinaryCompare and vbTextCompare. If you do not specify compare, the InStrRev method performs a binary comparison. | ||||||||||||||
vInStrRev | Variant Receives the position of a character or a character string in a text. Possible return values:
|
The following example searches a text in various character strings:
Dim MyPos MyPos = InStrRev("abcdabcde", "c") 'Returns 7 Call MsgBox(MyPos) MyPos = InStrRev("abcdabcde", "C") 'Returns 0 Call MsgBox(MyPos) MyPos = InStrRev("abcdabcde", "C", -1, vbTextCompare) 'Returns 7 Call MsgBox(MyPos)