Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Low As Single
- Public High As Single
- ' Filters source array with predicateName.
- Public Function Where(source() As Variant, predicateName As String) As Variant()
- Const PredicateNameIsEmpty As Integer = 513
- If predicateName = "" Then
- Call Err.Raise(PredicateNameIsEmpty, "predicateName", _
- "empty predicate name can't be used")
- End If
- Dim Result() As Variant
- Dim isFirst As Boolean
- isFirst = True
- For i = 0 To UBound(source)
- Dim suites As Boolean
- suites = Application.Run(predicateName, source(i))
- If suites Then
- If isFirst Then
- ReDim Preserve Result(0)
- isFirst = False
- Else
- ReDim Preserve Result(UBound(Result) + 1)
- End If
- Result(UBound(Result)) = source(i)
- End If
- Next i
- Where = Result
- End Function
- ' Converts array to string.
- Public Function ArrayToString(source() As Variant, Optional delimiter As String = ", ", _
- Optional startDelimiter As String = "[", Optional endDelimiter As String = "]")
- Dim Result As String
- Result = startDelimiter
- On Error Resume Next
- If UBound(source) >= LBound(source) Then
- For Each Item In source
- Result = Result & CStr(Item) & delimiter
- Next
- End If
- ArrayToString = Left(Result, Len(Result) - Len(delimiter)) & endDelimiter
- End Function
- Public Function IsGreaterZeroPredicate(value As Single) As Boolean
- IsGreaterZeroPredicate = value > 0
- End Function
- Public Function IsLessZeroPredicate(value As Single) As Boolean
- IsLessZeroPredicate = value < 0
- End Function
- Public Function IsInRangePredicate(value As Single) As Boolean
- IsInRangePredicate = value >= Low And value <= High
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement