VBScript Filter Function
Definisyon at Paggamit
Ang Filter function ay maaaring ibalik ang isang array na nagsimula sa 0, na naglalaman ng isang subset ng string array na batay sa tiyak na kundisyon ng pagpasok.
Komentaryo:Kung walang matugunan ang tumutugma sa parameter na value, ang Filter function ay ibabalik ang isang walang laman na array.
Komentaryo:Kung ang parameter na inputstrings ay Null o hindi isang-dimensiyonal na array, mangyayari ang pagkakamali.
Sintaksis
Filter(inputstrings, value[, include[, compare]])
Parameter | Description |
---|---|
inputstrings | Wahahati. Ang pangangailangan na isang-dimensiyonal na string array na dapat hahanapin. |
value | Required. The string to search for. |
include | Optional. Boolean value that specifies 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 use. |
Parameter compare value:
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