Class Microsoft.VisualBasic.Strings Syntax Dim result As String( ) = Filter(source, match[, include[, compare]])
source (required; String array or Object array) An array containing values to be filtered.
match (required; String) The substring of characters to find in the elements of the source array.
include (optional; Boolean) If true (the default value), Filter includes all matching values in the returned array; if False, Filter includes all non-matching values.
compare (optional; CompareMethod enumeration) Indicates the text comparison method. One of the following Microsoft.VisualBasic.CompareMethod enumeration values: Value | Description |
---|
Binary | Performs a binary (case-sensitive) comparison | Text | Performs a text (case-insensitive) comparison |
If omitted, Binary is used. Description The Filter function produces an array of matching (or non-matching) values from an array of source values. Usage at a Glance If no matches are found, Filter returns an empty array. Although the Filter function is primarily a string function, you can also filter numeric values. To do this, specify a source of type Object and populate this array with numeric values. Then assign the string representation of the numeric value you wish to filter onto the match parameter. The returned array contains string representations of the filtered numbers. For example: Dim sourceArray( ) As Object = _ {123, 222, 444, 139, 1, 12, 98, 908, 845, 22, 3, 9, 11} Dim targetArray( ) As String = Filter(sourceArray, "1") returns an array containing five elements: 123, 139, 1, 12, and 11. See Also Partition Function |