VBCE.com - The Premier Website For Visual Basic/CE Developers

 

*Dev Corner

Sample Code
Controls
Workarounds
Tips & Tricks
Q & A
Forums

*Goodies
Downloads
Software
Bookstore


*General
Home
What's New
General Info
Misc. Info


*News Worthy
News
Articles
Editorials
KB Articles
Reviews
Awards

*Miscellaneous
Web Links
Partners
Search
Feedback
Advertising

<% On Error Resume Next SiteStats() %>

Sponsors


More...


Filter Function Sample

   '==============================================================
    'Filter Sample                                                '
    '==============================================================

    'Description    Returns a zero-based array containing subset of
    '               a string array based on a specified filter criteria.
    
    'Syntax         Filter(InputStrings, Value[, Include[, Compare]])
        
    '               Part            Description
    '               ================================================
    '               InputStrings    Required. One-dimensional array
    '                               of strings to be searched.
    '               Value           Required. String to search for.
    '               Include         Optional. Boolean value indicating
    '                               whether to return substrings that
    '                               include or exclude Value. If
    '                               Include is True, Filter returns
    '                               the subset of the array that
    '                               contains Value as a substring.
    '                               If Include is False, Filter
    '                               returns the subset of the array
    '                               that does not contain Value as a
    '                               substring.
    '               Compare         Optional. Numeric value indicating
    '                               the kind of string comparison to use.
    '                               See Settings section for values.
    
    'Settings
    'The compare argument can have the following Values:
    
    'Constant           Value       Description
    'vbBinaryCompare    0           Perform a binary comparison.
    'vbTextCompare      1           Perform a textual comparison.
    'vbDatabaseCompare  2           Perform a comparison based on
    '                               information contained in the
    '                               database where the comparison
    '                               is to be performed.

    Dim myArray(5)
    Dim myResults
    Dim iLoop
    Dim msgString
    'Prepare Array
    myArray(0) = "one.bmp"
    myArray(1) = "two.bmp"
    myArray(2) = "three.bmp"
    myArray(3) = "four.txt"
    myArray(4) = "five.bmp"
    myArray(5) = "six.txt"
    'Get just ".txt" files
    myResults = Filter(myArray, ".txt", True)
    For iLoop = 0 To UBound(myResults)
        msgString = msgString & myResults(iLoop) & vbCrLf
    Next
    MsgBox "Text Files in Array:" & vbCrLf & msgString, vbInformation, "Filter Sample"
    'Get all non-".txt" files
    myResults = Filter(myArray, ".txt", False)
    msgString = ""
    For iLoop = 0 To UBound(myResults)
        msgString = msgString & myResults(iLoop) & vbCrLf
    Next
    MsgBox "Non Text Files in Array:" & vbCrLf & msgString, vbInformation, "Filter Sample"

 


VBCE.com is DevX Winner!

Unless otherwise noted, all information on VBCE.com is Copyright 1998 - 2002
Windows, Windows CE, and Visual Basic are trademarks of the Microsoft Corporation.
VBCE.com is not responsible for content on external sites.
Send all feedback to webmaster@vbce.com
Webmasters - feel free to link to
VBCE.com - Premier Website for Visual Basic/CE Development

Buy Books!