VBScript Filter Function

A Filter Function, which returns a zero-based array that contains a subset of a string array based on a specific filter criteria.


  • inputstrings, a Required parameter. This parameter corresponds to the array of strings to be searched.

  • value, a Required Parameter. This parameter corresponds to the string to search for against the inputstrings parameter.

  • include, an Optional Parameter. This is a Boolean value, which indicates whether or not to return the substrings that include or exclude.

  • compare, an Optional Parameter. This Parameter describes what string comparison method to be used.

    • 0 = vbBinaryCompare - Performs a binary comparison

    • 1 = vbTextCompare - Performs a textual comparison


<!DOCTYPE html>
      <script language = "vbscript" type = "text/vbscript">
         a = array("Red","Blue","Yellow")
         b = Filter(a,"B")
         c = Filter(a,"e")
         d = Filter(a,"Y")

         For each x in b
           Document.write("The Filter result 1: " & x & "<br />")

         For each y in c
           Document.write("The Filter result 2: " & y & "<br />")

         For each z in d
           Document.write("The Filter result 3: " & z & "<br />")


When the above code is saved as .HTML and executed in Internet Explorer, it produces the following result −

The Filter result 1: Blue
The Filter result 2: Red
The Filter result 2: Blue
The Filter result 2: Yellow
The Filter result 3: Yellow
Kickstart Your Career

Get certified by completing the course

Get Started