Filter(VB5)




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










( filtervb5.html )- by Paolo Puglisi - Modifica del 17/12/2023