InStr

返回指定字符串2在指定字符串1中的位置。 返回的位置为字符串2在字符串1中从左到右的起始位置(起始字符数)。

用法

InStr(String1,String2)

参数说明: String1  —— 字符串表达式,包含要寻找字符的字符串。
               String2  —— 字符串表达式,要寻找的字串。

注意

若搜索没有符合的字符,则返回0。

若搜索符合的字符出现不止一次,则返回第一个符合的位置

搜索区分大小写。

范例

InStr("Friday is the expiration day", "Friday");

会返回1,表示"Friday"在"Friday is the expiration day"中的起始位置为1。

InStr("Friday is the expiration day", "Monday");

会返回0,表示"Monday"没有出现在"Friday is the expiration day" 中。