devxlogo

Filter – A replacement for VB6’s Filter function under VB5

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 FunctionSub 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

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist