Export (0) Print
Expand All

Strings::InStrRev Method

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public:
static int InStrRev(
	String^ StringCheck, 
	String^ StringMatch, 
	int Start, 
	CompareMethod Compare
)

Parameters

StringCheck
Type: System::String

Required. String expression being searched.

StringMatch
Type: System::String

Required. String expression being searched for.

Start
Type: System::Int32

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.

Compare
Type: Microsoft.VisualBasic::CompareMethod

Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. If omitted, a binary comparison is performed. See Settings for values.

Return Value

Type: System::Int32

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

ExceptionCondition
ArgumentException

Start = 0 or Start < -1.

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.

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)

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft