dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB5
Expertise: Intermediate
Apr 1, 2000

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Filter - A replacement for VB6's Filter function under VB5

' A replace for the Filter function under VB4 and VB5
'
' Note that the source array is modified. For this reason
' this is declared as a Sub rather than a Function

Sub Filter(arr() As String, ByVal Search As String, Optional ByVal Include As _
    Boolean, Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare)
    Dim index As Long
    Dim count As Long
    
    count = LBound(arr) - 1
    
    For index = LBound(arr) To UBound(arr)
        If (InStr(1, arr(index), Search, CompareMethod) > 0) = Include Then
            ' this item must be included
            count = count + 1
            If index <> count Then
                ' copy data only if necessary
                arr(count) = arr(index)
            End If
        End If
    Next
    
    ' trim items in excess
    If count < UBound(arr) Then
        ReDim Preserve arr(LBound(arr) To count) As String
    End If
    
End Sub
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date