国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

VBS教程:函數(shù)-InStr 函數(shù)

2020-06-26 18:02:00
字體:
來源:轉載
供稿:網友

InStr 函數(shù)

返回某字符串在另一字符串中第一次出現(xiàn)的位置。

InStr([start, ]string1, string2[, compare])

參數(shù)

start

可選項。數(shù)值表達式,用于設置每次搜索的開始位置。如果省略,將從第一個字符的位置開始搜索。如果 start 包含 Null,則會出現(xiàn)錯誤。如果已指定 compare,則必須要有 start 參數(shù)。

string1

必選項。接受搜索的字符串表達式。

string2

必選項。要搜索的字符串表達式。

compare

可選項。指示在計算子字符串時使用的比較類型的數(shù)值。有關數(shù)值,請參閱“設置”部分。如果省略,將執(zhí)行二進制比較。

設置

compare 參數(shù)可以有以下值:

常數(shù) 描述
vbBinaryCompare 0 執(zhí)行二進制比較。
vbTextCompare 1 執(zhí)行文本比較。

返回值

InStr 函數(shù)返回以下值:

如果 InStr 返回
string1 為零長度 0
string1 為 Null Null
string2 為零長度 start
string2 為 Null Null
string2 沒有找到 0
在 string1 中找到 string2 找到匹配字符串的位置
start > Len(string2) 0

說明

下面的示例利用 InStr 搜索字符串:

Dim SearchString, SearchChar, MyPosSearchString ="XXpXXpXXPXXP"   ' String to search in.SearchChar = "P"   ' Search for "P".MyPos = Instr(4, SearchString, SearchChar, 1)   ' A textual comparison starting at position 4. Returns 6.MyPos = Instr(1, SearchString, SearchChar, 0)   ' A binary comparison starting at position 1. Returns 9.    MyPos = Instr(SearchString, SearchChar)   ' Comparison is binary by default (last argument is omitted). Returns 9.MyPos = Instr(1, SearchString, "W")   ' A binary comparison starting at position 1. Returns 0 ("W" is not found).

注意 InStrB 函數(shù)使用包含在字符串中的字節(jié)數(shù)據(jù),所以 InStrB 返回的不是一個字符串在另一個字符串中第一次出現(xiàn)的字符位置,而是字節(jié)位置。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 乌拉特后旗| 夏河县| 五峰| 宣化县| 陇南市| 凌海市| 新绛县| 东源县| 额敏县| 岱山县| 铜梁县| 南部县| 清涧县| 雅安市| 宁德市| 松原市| 河东区| 阿瓦提县| 富顺县| 曲周县| 泰宁县| 师宗县| 临海市| 年辖:市辖区| 寻乌县| 宜君县| 房产| 通辽市| 梅河口市| 宜丰县| 兰州市| 深州市| 内乡县| 苏尼特右旗| 临汾市| 息烽县| 贺兰县| 襄垣县| 灌云县| 霍州市| 庆城县|