There is a Filter function in VBScript that can be used to filter an array and return a subset array of the original array. Syntax description:
Filter function
Returns a zero-based array containing a subset of a string array based on a specified filter condition.
Filter(InputStrings, Value[, Include[, Compare]])
parameter
InputStrings
Required. A one-dimensional array in which to search for strings.
Value
Required. The string to search for.
Include
Optional. Boolean value that specifies whether the returned substring contains Value. If Include is True, Filter returns a subset of the array containing the substring Value. If Include is False, Filter returns a subset of the array that does not contain the substring Value.
Compare
Optional. Numeric value indicating the type of comparison string used. See the Value Settings section.
set up
The Compare parameter can have the following values:
constant
value
describe
vbBinaryCompare
0
Perform a binary comparison.
vbTextCompare
1
Perform text comparison.
illustrate
If no matching value is found in InputStrings, Filter returns an empty array. If InputStrings is Null or is not a one-dimensional array, an error occurs.
The array returned by the Filter function contains only enough elements to contain the number of matches.
The following example uses the Filter function to return an array containing the search condition Mon:
Copy the code code as follows:
DimMyIndex
Dim MyArray (3)
MyArray(0) = Sunday
MyArray(1) = Monday
MyArray(2) = Tuesday
MyIndex = Filter(MyArray, Mon) 'MyIndex(0) contains Monday.
You need to pay attention to the red position, MyIndex is an array! ~
Copy the code code as follows:
Dim MyIndex,IndexItem
DimMyArray(2)
MyArray(0) = Sunday
MyArray(1) = Monday
MyArray(2) = Monday
MyIndex = Filter(MyArray,Tuesday)
For IndexItem = 0 To UBound(MyIndex)
Response.Write MyIndex(Monday)&<br />
Next