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, 
	[OptionalAttribute] int Start, 
	[OptionalAttribute] CompareMethod Compare
)
public static int InStrRev (
	String StringCheck, 
	String StringMatch, 
	/** @attribute OptionalAttribute() */ int Start, 
	/** @attribute OptionalAttribute() */ CompareMethod Compare
)
public static function InStrRev (
	StringCheck : String, 
	StringMatch : String, 
	Start : int, 
	Compare : CompareMethod
) : int
Not applicable.

Parameters

StringCheck

Required. String expression being searched.

StringMatch

Required. String expression being searched for.

Start

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

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

If StringCheck is zero-length, InStrRev returns 0. If StringMatch is zero-length, InStrRev returns Start. If StringMatch is not found, InStrRev returns 0. If StringMatch is found within StringCheck, InStrRev returns position at which the first match is found, starting with the right side of the string. If Start is greater than length of StringMatch, InStrRev returns 0.

For more detailed information, see the Visual Basic topic InStrRev Function (Visual Basic).

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)

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft