Returns the position of the first occurrence of one string within another, starting from the right side of the string.
Public Function InStrRev( ByVal StringCheck As String, ByVal StringMatch As String, Optional ByVal Start As Integer = -1, Optional ByVal Compare As CompareMethod = CompareMethod.Binary ) As Integer
The Compare argument can have the following values:
Constant | Description |
---|---|
Binary | Performs a binary comparison |
Text | Performs a textual comparison |
InStrRev returns the following values:
If | InStrRev returns |
---|---|
StringCheck is zero-length | 0 |
StringMatch is zero-length | start |
StringMatch is not found | 0 |
StringMatch is found within StringCheck | Position at which the first match is found, starting with the left side of the string. |
Start is greater than length of StringMatch | 0 |
Exception type | Error number | Condition |
---|---|---|
5 | Start = 0 or Start < -1. |
Note that the syntax for the InStrRev function is not the same as the syntax for the InStr function.
This example demonstrates the use of the InStrRev function:
Dim myString As String = "the quick brown fox jumps over the lazy dog" Dim myNumber As Integer MyNumber = InStrRev(myString, "the")
' Returns 32. MyNumber = InStrRev(myString, "the", 16)
' Returns 1