常數(shù) | 值 | 描述 |
---|---|---|
vbBinaryCompare | 0 | 執(zhí)行二進(jìn)制比較。 |
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é)位置。
標(biāo)簽:達(dá)州 內(nèi)蒙古 資質(zhì)掛靠 丹東 鶴壁 南京 張掖 柳州
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《VBS教程:函數(shù)-InStr 函數(shù)》,本文關(guān)鍵詞 VBS,教程,函數(shù),-InStr,VBS,教程,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。