This approach was born out of wanting to pass a logical expression (E.G. ">=10000") as a parameter to a function.
So, I built an Enum and a function to use it to evaluate logical expressions.
Is this a good, maintainable, scalable approach?
Public Enum comparisonOperator
'/ Used [[ ]] because the outer set escape the inner brackets for the Enum list, which will then escape the operator when chosen as a value. E.G. they will appear as "Operator = [<]" in code.
[[<]] = 1
[[<=]] = 2
[[=]] = 3
[[>=]] = 4
[[>=]][[>]] = 5
End Enum
Public Function ComparisonIsTrue(ByVal sourceValue As Variant, ByVal operator As comparisonOperator, ByVal comparisonValue As Variant) As Boolean
Dim isTrue As Boolean
Select Case operator
Case Is = 1 '/ <
isTrue = (sourceValue < comparisonValue)
Case Is = 2 '/ <=
isTrue = (sourceValue <= comparisonValue)
Case Is = 3 '/ =
isTrue = (sourceValue = comparisonValue)
Case Is = 4 '/ >=
isTrue = (sourceValue >= comparisonValue)
Case Is = 5 '/ >
isTrue = (sourceValue > comparisonValue)
Case Else
'/ Error Handling
Stop
End Select
ComparisonIsTrue = isTrue
End Function