Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

VBScript Filter Function

❮ Complete VBScript Reference

The Filter function returns a zero-based array that contains a subset of a string array based on a filter criteria.

Note: If no matches of the value parameter are found, the Filter function will return an empty array.

Note: If the parameter inputstrings is Null or is NOT a one-dimensional array, an error will occur.

Syntax

Filter(inputstrings,value[,include[,compare]])
Parameter Description
inputstrings Required. A one-dimensional array of strings to be searched
value Required. The string to search for
include Optional. A Boolean value that indicates whether to return the substrings that include or exclude value. True returns the subset of the array that contains value as a substring. False returns the subset of the array that does not contain value as a substring. Default is True.
compare Optional. Specifies the string comparison to use.

Can have one of the following values:

  • 0 = vbBinaryCompare - Perform a binary comparison
  • 1 = vbTextCompare - Perform a textual comparison

Examples

Example 1

Filter: items that contains "S"

<%

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
for each x in b
    response.write(x & "<br />")
next

%>

The output of the code above will be:

Sunday
Saturday
Show Example »

Example 2

Filter: items that does NOT contain "S" (include=False):

<%

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
for each x in b
    response.write(x & "<br />")
next

%>

The output of the code above will be:

Monday
Tuesday
Wednesday
Thursday
Friday
Show Example »

Example 3

Filter: items that contains "S", with a textual comparison (compare=1):

<%

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
for each x in b
    response.write(x & "<br />")
next

%>

The output of the code above will be:

Sunday
Tuesday
Wednesday
Thursday
Saturday
Show Example »

❮ Complete VBScript Reference
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.