VB的問題 函式 instr()的每個引數意思

2021-06-02 11:20:14 字數 842 閱讀 7879

instr 函式 返回 variant (long),指定一字串在另一字串中最先出現的位置。

語法 instr([start, ]string1, string2[, compare])

instr 函式的語法具有下面的引數:部分 說明

start 可選引數。為數值表示式,設定每次搜尋的起點。如果省略,將從第乙個字元的位置開始。如果 start 包含 null,將發生錯誤。如果指定了 compare 引數,則一定要有 start 引數。

string1 必要引數。接受搜尋的字串表示式。

string2 必要引數。被搜尋的字串表示式。

compare 可選引數。指定字串比較。如果 compare 是 null,將發生錯誤。如果省略 compare,option compare 的設定將決定比較的型別。

設定 compare 引數設定為:常數 值 描述 vbusecompareoption -1 使用option compare 語句設定執行乙個比較。

vbbinarycompare 0 執行乙個二進位制比較。

vbtextcompare 1 執行乙個按照原文的比較。

vbdatabasecompare 2 僅適用於microsoft access,執行乙個基於資料庫中資訊的比較。

返回值如果 instr返回 string1 為零長度 0 string1 為 null null string2 為零長度 start string2 為 null null string2 找不到 0 在 string1 中找到string2 找到的位置 start > string2 0 說明instrb 函式作用於包含在字串中的位元組資料。所以 instrb 返回的是位元組位置,而不是字元位置。

instr 函式的用法

最簡單例子 在abcd中查詢a的位置,從第乙個字母開始查,查詢第一次出現時的位置 select instr abcd a 1,1 from dual 1 select instr abcd c 1,1 from dual 3 select instr abcd e 1,1 from dual 0 應...

instr函式的使用

對於instr函式,我們經常這樣使用 從乙個字串中查詢指定子串的位置。例如 sql select instr yuechaotianyuechao ao position from dual position 6從字串 yuechaotianyuechao 的第乙個位置開始,向後查詢第乙個出現子串 ...

instr 函式的格式

格式一 instr string1,string2 instr 源字串,目標字串 注 在oracle plsql中,instr函式返回要擷取的字串在源字串中的位置。只檢索一次,也就是說從字元的開始到字元的結尾就結束。格式一1 select instr helloworld l from dual 返...