Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

VBScript Filter Function

VBScript Filter Function


VBScript reference manual Complete VBScript Reference Manual


The Filter function returns a zero-based array containing a subset of a string array based on a specific filter criterion.

**Note:** If no value matching the value parameter is found, the Filter function returns an empty array.

**Note:** If the inputstrings parameter is Null or is not a one-dimensional array, an error occurs.

Syntax

Filter(inputstrings,value[,include[,compare]])

Parameters Description
inputstrings Required. A one-dimensional array of strings to search.
value Required. The string to search for.
include Optional. A Boolean value specifying whether the returned substrings include Value. If Include is True, Filter returns an array subset containing the substring Value. If Include is False, Filter returns an array subset not containing the substring Value. The default is True.
compare Optional. Specifies the type of string comparison to use.

The following values can be used:

  • 0 = vbBinaryCompare - Performs a binary comparison
  • 1 = vbTextCompare - Performs a textual comparison
  • |

    Example

    Example 1

    Filter: items containing "S":

    The example above produces the following output:

    Sunday

    Saturday

    Try it »

    Example 2

    Filter: items not containing "S" (include=False):

    The example above produces the following output:

    Monday

    Tuesday

    Wednesday

    Thursday

    Friday

    Try it »

    Example 3

    Filter: items containing "S" using a textual comparison (compare=1):

    The example above produces the following output:

    Sunday

    Tuesday

    Wednesday

    Thursday

    Saturday

    Try it »


    VBScript reference manual Complete VBScript Reference Manual