O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Filter Function

Class

Microsoft.VisualBasic.Strings

Syntax

Filter(Source, Match[, Include[, Compare]])
Source (required; String or Object)

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)

A Boolean (True or False) value. If True (the default value), Filter includes all matching values in the returned array; if False, Filter excludes all matching values (or, to put it another way, includes all nonmatching values).

Compare (optional; CompareMethod enumeration)

A constant whose value can be CompareMethod.Text or CompareMethod.Binary (the default).

Return Value

A 0-based String array of the elements filtered from Source

Description

The Filter function produces an array of matching values from an array of source values that either match or do not match a given filter string.

Put another way, individual elements are copied from a source array to a target array if they either match (Include is True) or do not match (Include is False) a filter string.A match occurs for an array element if Match is a substring of the array element.

Rules at a Glance

  • The default Include value is True.

  • The default Compare value is CompareMethod.Binary.

  • CompareMethod.Binary is case sensitive; that is, Filter matches both character and case. In contrast, CompareMethod.Text is case insensitive, matching only character regardless of case.

  • If no matches are found, Filter returns an empty ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required