Syntax description:
Filter Function
Returns an array with a subscript starting from zero, which contains a subset of a string array based on a specific filter condition.
Filter (InputStrings, Value [, Include [, Compare])
Parameters
InputStrings
Required. A one-dimensional array in which a string is to be searched.
Value
Required. The string to be searched.
Include
Optional. Boolean Value, which specifies whether the returned substring contains Value. If Include is True, Filter returns an array subset that contains the sub-string Value. If Include is False, the Filter returns an array subset that does not contain the sub-string Value.
Compare
Optional. Numeric value indicates the comparative string type. See value setting.
Set
The Compare parameter can have the following values:
Constant
Value
Description
VbBinaryCompare
0
Perform binary comparison.
VbTextCompare
1
Execute text comparison.
Description
If no Value matches the Value in InputStrings, the Filter returns an empty array. If InputStrings is Null or not a one-dimensional array, an error occurs.
The array returned by the Filter function only contains elements that are sufficient to contain the number of matching items.
The following example uses the Filter function to return an array containing the Search Condition "Mon:Copy codeThe Code is as follows: Dim MyIndex
Dim MyArray (3)
MyArray (0) = "Sunday"
MyArray (1) = "Monday"
MyArray (2) = "Tuesday"
MyIndex = Filter (MyArray, "Mon") 'myindex (0) contains "Monday ".
Note that MyIndex is an array !~Copy codeThe Code is as follows: 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