ASP 使用Filter函數(shù)來檢索數(shù)組的實現(xiàn)代碼
2024-05-04 10:59:56
供稿:網(wǎng)友
語法說明:
Filter 函數(shù)
返回下標(biāo)從零開始的 數(shù)組,其中包含以特定過濾條件為基礎(chǔ)的字符串?dāng)?shù)組的子集。
Filter(InputStrings, Value[, Include[, Compare]])
參數(shù)
InputStrings
必選項。一維數(shù)組,要在其中搜索字符串。
Value
必選項。要搜索的字符串。
Include
可選項。Boolean 值,指定返回的子字符串是否包含 Value。如果 Include 為 True,F(xiàn)ilter 將返回包含子字符串 Value 的數(shù)組子集。如果 Include 為 False,F(xiàn)ilter 將返回不包含子字符串 Value 的數(shù)組子集。
Compare
可選項。數(shù)字值指出使用的比較字符串 類型.請參閱值設(shè)置部分.
設(shè)置
Compare 參數(shù)可以有以下值:
常數(shù)
值
描述
vbBinaryCompare
0
執(zhí)行二進(jìn)制比較。
vbTextCompare
1
執(zhí)行文本比較。
說明
如果在 InputStrings 中沒有找到與 Value 匹配的值,F(xiàn)ilter 將返回空數(shù)組。如果 InputStrings 為 Null 或者不是一維數(shù)組,則會發(fā)生錯誤。
由 Filter 函數(shù)返回的數(shù)組僅包含足以包含匹配項數(shù)目的元素。
下面例子利用 Filter 函數(shù)返回包含搜索條件 "Mon" 的數(shù)組:
復(fù)制代碼 代碼如下:
Dim MyIndex
Dim MyArray (3)
MyArray(0) = "Sunday"
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyIndex = Filter(MyArray, "Mon") 'MyIndex(0) 包含 "Monday"。
在紅色的位置需要注意一下,MyIndex是一個數(shù)組!~
復(fù)制代碼 代碼如下:
Dim MyIndex,IndexItem
Dim MyArray(2)
MyArray(0) = "Sunday"
MyArray(1) = "Monday"
MyArray(2) = "Monday"
MyIndex = Filter(MyArray,"Tuesday")
For IndexItem = 0 To UBound(MyIndex)
Response.Write MyIndex(Monday)&"<br />"
Next
您可能感興趣的文章:
asp取得數(shù)組中的最大值的方法asp下使用數(shù)組存放數(shù)據(jù)的代碼asp 得到動態(tài)數(shù)組中元素的個數(shù)asp.net 數(shù)組中字符串替換的幾種方式asp 動態(tài)數(shù)組 提供Add、Insert、Remove、RemoveAt、Search等方法。asp.net 字符串、二進(jìn)制、編碼數(shù)組轉(zhuǎn)換函數(shù)asp.net通過js實現(xiàn)Cookie創(chuàng)建以及清除Cookie數(shù)組的代碼asp textarea 多行數(shù)組分割處理方法asp 數(shù)組 重復(fù)刪除函數(shù)(錯新站長站增強版)ASP 過濾數(shù)組重復(fù)數(shù)據(jù)函數(shù)(加強版)asp數(shù)組的使用介紹Asp與JS的數(shù)組和字符串下標(biāo)介紹asp中使用redim、preserve創(chuàng)建動態(tài)數(shù)組實例ASP定義數(shù)組方法的技巧