Filter()
函式返回一個基於零的陣列,其中包含基於特定過濾條件的字串陣列的子集。
Filter(inputstrings,value[,include[,compare]])
引數說明
inputstrings
引數搜尋的字串。新增一個模組,並新增以下程式碼 -
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