Strings.InStrRev(String, String, Int32, CompareMethod) 方法

定義

傳回某個字串在另一個字串中第一次出現的位置,從字串的右邊開始。

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

參數

StringCheck
String

必要。 正在搜尋的字串運算式。

StringMatch
String

必要。 正在搜尋的字串運算式。

Start
Int32

選擇性。 為每一個搜尋設定以 1 起始的位置之數值運算式,從字串的左邊開始。 如果省略 Start,則會使用 -1,表示搜尋會從最後一個字元位置開始。 從右到左進行的搜尋。

Compare
CompareMethod

選擇性。 數值,表示在評估子字串時要使用的比較類型。 如果省略,則會執行二進位比較。 請參閱數值的設定。

傳回

如果InStrRev 會傳回
StringCheck 的長度為零0
StringMatch 的長度為零 Start
StringMatch 找不到。0
StringMatch 中找到 StringCheck找到第一個符合項目的位置,從字串的右邊開始。
Start 大於 StringMatch 的長度0

例外狀況

Start = 0 或 Start< -1。

範例

這個範例示範如何使用 函 InStrRev 式。

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)

備註

請注意,函式的 InStrRev 語法與函式的 InStr 語法不同。

Compare 變數可以有下列值。

常數 描述
Binary 執行二進位比較。
Text 執行文字比較。

適用於

另請參閱