
- VBScript Tutorial
- VBScript - Home
- VBScript - Overview
- VBScript - Syntax
- VBScript - Enabling
- VBScript - Placement
- VBScript - Variables
- VBScript - Constants
- VBScript - Operators
- VBScript - Decisions
- VBScript - Loops
- VBScript - Events
- VBScript - Cookies
- VBScript - Numbers
- VBScript - Strings
- VBScript - Arrays
- VBScript - Date
- VBScript Advanced
- VBScript - Procedures
- VBScript - Dialog Boxes
- VBScript - Object Oriented
- VBScript - Reg Expressions
- VBScript - Error Handling
- VBScript - Misc Statements
- VBScript Useful Resources
- VBScript - Questions and Answers
- VBScript - Quick Guide
- VBScript - Useful Resources
- VBScript - Discussion
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.
Syntax
Filter(inputstrings,value[,include[,compare]])
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
Example
<!DOCTYPE html> <html> <body> <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 />") Next For each y in c Document.write("The Filter result 2: " & y & "<br />") Next For each z in d Document.write("The Filter result 3: " & z & "<br />") Next </script> </body> </html>
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