例子1:
Dim aa(10) As String
Dim
bb
Dim i As Integer
For
i = 0 To 9
aa(i) = "aa" + Str(i)
Next
bb = Filter(aa, "aa")
Label1.Caption = bb(
0)
Label2.Caption = bb(
1)
Label3.Caption = bb(
2)
'这时Label1显示aa 0,Label2显示aa 1,Label3显示aa 2。bb我也不知设为什么类型,所以就没设定。

例子2:
Dim b() As String
Dim
a(10) As String
Dim
i As Integer
For
i = 0 To 10
a(i) = Trim(Str(i))
Next i
a(
1) = "5"
b = Filter(a, "5")
MsgBox UBound(b,
1)
b = Filter(a,
"5") '就是将A数组中所有="5"的项附给B数组

例子3:
'用Filter函数取出有可能与所选项重复的值
'NewArray和MatchArray都是数组,一般用在数组的筛选上!
MatchArray = Filter(NewArray, orgArray(i), True, vbTextCompare)

 
目前有0条回应
Comment
Trackback
你目前的身份是游客,请输入昵称和电邮!