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

Definice

Vrátí pozici prvního výskytu jednoho řetězce v rámci druhého počínaje od pravé strany řetězce.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);
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

Parametry

StringCheck
String

Povinná hodnota.Required. Hledaný výraz řetězce.String expression being searched.

StringMatch
String

Povinná hodnota.Required. Hledaný výraz řetězce.String expression being searched for.

Start
Int32

Nepovinný parametr.Optional. Číselný výraz nastavuje jednu počáteční pozici pro každé hledání od levé strany řetězce.Numeric expression setting the one-based starting position for each search, starting from the left side of the string. Pokud Start je vynechán, je použita hodnota-1, což znamená, že hledání začíná na poslední pozici znaku.If Start is omitted then -1 is used, meaning the search begins at the last character position. Hledání pak pokračuje zprava doleva.Search then proceeds from right to left.

Compare
CompareMethod

Nepovinný parametr.Optional. Číselná hodnota označující druh porovnání, které se má použít při vyhodnocování podřetězců.Numeric value indicating the kind of comparison to use when evaluating substrings. Je-li tento parametr vynechán, je provedeno binární porovnání.If omitted, a binary comparison is performed. Viz nastavení pro hodnoty.See Settings for values.

Návraty

Int32
Pokud uživatelIfInStrRev vrátíInStrRev returns
StringCheck je nulová délka StringCheck is zero-length00
StringMatch je nulová délka StringMatch is zero-length Start
StringMatch nebyl nalezen StringMatch is not found00
StringMatch byl nalezen v rámci StringCheck StringMatch is found within StringCheckPozice, ve které je první shoda nalezena, počínaje pravou stranou řetězce.Position at which the first match is found, starting with the right side of the string.
Start je větší než délka StringMatch Start is greater than length of StringMatch00

Výjimky

Start = 0 nebo Start < -1.Start = 0 or Start < -1.

Příklady

Tento příklad ukazuje použití InStrRev funkce.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)

Poznámky

Všimněte si, že syntaxe InStrRev funkce není shodná se syntaxí InStr funkce.Note that the syntax for the InStrRev function is not the same as the syntax for the InStr function.

CompareArgument může obsahovat následující hodnoty.The Compare argument can have the following values.

KonstantaConstant DescriptionDescription
Binary Provede binární porovnání.Performs a binary comparison.
Text Provede textové porovnání.Performs a textual comparison.

Platí pro

Viz také