Filter Procedure |
Version 7 |
Returns a array in a variant containing a subset of a string array based on a specified filter criteria.
vrStrArray = Filter ( vrInStrArray, sFilter, [bInclude], [bCompareNoCase] )
The Filter procedure syntax has the following parts:
Name |
Type |
Description |
vrStrArray |
Variant |
Return Value: a variant containing a subset of a string array based on the specified filter criteria. |
vrInStrArray |
Val Variant |
Variant containing a string array |
sFilter |
Val BString |
Substring being searched for. |
bInclude |
Val Bool |
Optional. Boolean value indicating whether to return substrings that include or exclude Value. If Include is True(Default), Filter returns the subset of the array that contains 'sFilter' as a substring. If Include is False, Filter returns the subset of the array that does not contain 'sFilter' as a substring. |
bCompareNoCase |
[Val] Bool |
True (default) means no-case comparison, and False means case comparison. |
For any invalid input parameters, Filter will return an empty string array in a variant.
In the following example Filter returns the array containing the search criteria "Mon":
as[0]="Monday"
as[1]="Tuesday"
as[2]="Wednesday"
vr=as
vr=Filter(vr, "Mon")
iSize=VarDimSize(vr, 0)
if iSize>0
Redim as [iSize]
as=vr
for i=0 to iSize-1
print as[i]
next
endif
prints only one item:
Monday
If you call Filter with the Include flag False,
vr=Filter(vr, "Mon", FALSE)
iSize=VarDimSize(vr, 0)
if iSize>0
as=vr
for i=0 to Internal.VarDimSize(vr, 0)-1
print as[i]
next
endif
prints two items:
Tuesday
Wednesday