VBScript Filter functie
Definitie en gebruik
De functie Filter kan een array retourneren die gebaseerd is op 0, en deze array bevat een subset van de string array op basis van een specifieke filterconditie.
Opmerking:Als de functie Filter geen waarde kan vinden die overeenkomt met de parameter value, zal de functie een lege array retourneren.
Opmerking:Als de parameter inputstrings null is of geen een维ige array is, zal een fout optreden.
Syntax
Filter(inputstrings,value[,include[,compare]])
Parameter | Description |
---|---|
inputstrings | Verplicht. Een een维ige string array die moet worden doorzocht. |
value | Required. The string to be searched. |
include | Optional. Boolean value specifying whether the returned substring contains Value. If Include is True, Filter will return a subset of the array that contains the substring Value. If Include is False, Filter will return a subset of the array that does not contain the substring Value. |
compare | Optional. Specifies the type of string comparison to be used. |
The value of the parameter 'compare':
Constant | Value | Description |
---|---|---|
vbBinaryCompare | 0 | Execute binary comparison. |
vbTextCompare | 1 | Execute text comparison. |
Instance
Example 1
dim a(5),b a(0)="Saturday" a(1)="Sunday" a(2)="Monday" a(3)="Tuesday" a(4)="Wednesday" b=Filter(a,"n") document.write(b(0)) document.write(b(1)) document.write(b(2))
Output:
Sunday Monday Wednesday
Example 2
dim a(5),b a(0)="Saturday" a(1)="Sunday" a(2)="Monday" a(3)="Tuesday" a(4)="Wednesday" b=Filter(a,"n",false) document.write(b(0)) document.write(b(1)) document.write(b(2))
Output:
Saturday Tuesday