Filter function
Returns a zero-based array containing a subset of a string array based on a specific filter condition.
Filter(InputStrings, Value[, Include[, Compare]])
Parameters
Inputstrings
Required option. A one-dimensional array in which to search for strings.
Value
Required option. The string to search for.
Include
Options available. Boolean value that specifies whether the returned substring contains Value. If include is True,Filter returns a subset of the array that contains the substring Value . If include is False,Filter returns a subset of the array that does not contain the substring Value .
Compare
Options available. Numeric values indicate the type of comparison string used. See the Value Settings section.
Set up
The Compare parameter can have the following values:
Constants |
value |
Description |
Vbbinarycompare |
0 |
Performs a binary comparison. |
vbTextCompare |
1 |
Performs a text comparison. |
Description
If no value is found in inputstrings , theFilter returns an empty array. If inputstrings is Null or is not a one-dimensional array, an error occurs.
The array returned by the Filter function contains only elements sufficient to contain the number of matches.
The following example uses the Filter function to return an array containing the search condition "Mon":
Dim Myindexdim myarray (3) myarray (0) = "Sunday" myarray (1) = "Monday" myarray (2) = "Tuesday" Myindex = Filter ( myarray , "Mon" ) ' myindex (0) The
contains Monday
.