- VBA 教程
- VBA - 主頁
- VBA - 概述
- VBA - Excel 宏
- VBA - Excel 術語
- VBA - 宏註釋
- VBA - 訊息框
- VBA - 輸入框
- VBA - 變數
- VBA - 常量
- VBA - 運算子
- VBA - 決策
- VBA - 迴圈
- VBA - 字串
- VBA - 日期和時間
- VBA - 陣列
- VBA - 函式
- VBA - 子程式
- VBA - 事件
- VBA - 錯誤處理
- VBA - Excel 物件
- VBA - 文字檔案
- VBA - 程式設計圖表
- VBA - 使用者窗體
- VBA 實用資源
- VBA - 快速指南
- VBA - 實用資源
- VBA - 討論
VBA - Filter 函式
Filter 函式,它返回基於特定篩選條件的字串陣列的子集,該子集採用零為基準的陣列。
語法
Filter(inputstrings,value[,include[,compare]])
引數說明
Inputstrings − 必需引數。該引數對應於要搜尋的字串陣列。
Value − 必需引數。該引數對應於針對 inputstrings 引數搜尋的字串。
Include − 可選引數。該引數的值為布林值,它指示是否返回子字串的包含或排除情況。
Compare − 可選引數。該引數描述要使用哪種字串比較方法。
0 = vbBinaryCompare - 執行二進位制比較
1 = vbTextCompare - 執行文字比較
示例
新增按鈕並新增以下函式。
Private Sub Constant_demo_Click()
Dim a,b,c,d as Variant
a = array("Red","Blue","Yellow")
b = Filter(a,"B")
c = Filter(a,"e")
d = Filter(a,"Y")
For each x in b
msgbox("The Filter result 1: " & x)
Next
For each y in c
msgbox("The Filter result 2: " & y)
Next
For each z in d
msgbox("The Filter result 3: " & z)
Next
End Sub
執行上述函式時,它會產生以下輸出。
The Filter result 1: Blue The Filter result 2: Red The Filter result 2: Blue The Filter result 2: Yellow The Filter result 3: Yellow
vba_arrays.htm
廣告
