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 函数

❮ VBScript 完整参考

Filter 函数返回一个基于零的数组,该数组包含基于筛选条件的字符串数组的子集。

注意:如果未找到 value 参数的匹配项,则 Filter 函数将返回一个空数组。

注意:如果参数 inputstrings 为 Null 或不是一维数组,则会发生错误。

语法

Filter(inputstrings,value[,include[,compare]])
参数 描述
inputstrings 必需。要搜索的一维字符串数组
value 必需。要搜索的字符串
include 可选。一个布尔值,指示是否返回包含或排除 value 的子字符串。True 返回包含 value 作为子字符串的数组子集。False 返回不包含 value 作为子字符串的数组子集。默认值为 True。
compare 可选。指定要使用的字符串比较。

可以具有以下值之一

  • 0 = vbBinaryCompare - 执行二进制比较
  • 1 = vbTextCompare - 执行文本比较

例子

示例 1

Filter:包含“S”的项目

<%

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

%>

上面代码的输出将是

Sunday
Saturday
显示示例 »

示例 2

Filter:不包含“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

%>

上面代码的输出将是

Monday
Tuesday
Wednesday
Thursday
Friday
显示示例 »

示例 3

Filter:包含“S”的项目,使用文本比较(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

%>

上面代码的输出将是

Sunday
Tuesday
Wednesday
Thursday
Saturday
显示示例 »

❮ VBScript 完整参考
×

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.