Strings.InStrRev(String, String, Int32, CompareMethod) Method


Returns the position of the first occurrence of one string within another, starting from the right side of the string.

public static int InStrRev (string StringCheck, string StringMatch, int Start = -1, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
static member InStrRev : string * string * int * Microsoft.VisualBasic.CompareMethod -> int
Public Function InStrRev (StringCheck As String, StringMatch As String, Optional Start As Integer = -1, Optional Compare As CompareMethod = Microsoft.VisualBasic.CompareMethod.Binary) As Integer



Required. String expression being searched.


Required. String expression being searched for.


Optional. Numeric expression setting the one-based starting position for each search, starting from the left side of the string. If Start is omitted then -1 is used, meaning the search begins at the last character position. Search then proceeds from right to left.


Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. If omitted, a binary comparison is performed. See Settings for 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 right side of the string.
Start is greater than length of StringMatch 0


Start = 0 or Start < -1.


This example demonstrates the use of the InStrRev function.

Dim testString As String = "the quick brown fox jumps over the lazy dog"
Dim testNumber As Integer
' Returns 32.
testNumber = InStrRev(testString, "the")
' Returns 1.
testNumber = InStrRev(testString, "the", 16)


Note that the syntax for the InStrRev function is not the same as the syntax for the InStr function.

The Compare argument can have the following values.

Constant Description
Binary Performs a binary comparison.
Text Performs a textual comparison.

Applies to

See also