Strings.InStrRev(String, String, Int32, CompareMethod) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回从字符串右侧开始的另一个字符串的第一个匹配项的位置。
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
可选。 数值表达式设置每个搜索的基于一个的起始位置,从字符串左侧开始。 如果 Start 省略,则使用 -1,这意味着搜索从最后一个字符位置开始。 然后,搜索从右到左继续。
- Compare
- CompareMethod
可选。 指示计算子字符串时要使用的比较类型的数值。 如果省略,则执行二进制比较。 请参阅“设置”了解值。
返回
| 如果 | InStrRev 返回值 |
|---|---|
StringCheck 为零长度 | 0 |
StringMatch 为零长度 |
Start
|
StringMatch 找不到 | 0 |
|
| 找到第一个匹配的位置,从字符串右侧开始。 |
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 |
执行文本比较。 |
适用于
另请参阅
- InStr
- Visual BasicStrings>
- Visual Basic 中的字符串简介