If ComparisonIsTrue(thisPost, ComparisonOperator.NotEqualTo, goodCode) Then Me.Answer This is a follow-on to a global enum for comparison operators. I wanted to pass a logical expression E.G. &gt;= someValue as a parameter to a function, so I made an Enum and an accompanying function to analyse logical expressions.



Is my approach a good way to implement this functionality in VBA?



Public Enum ComparisonOperator
    NotEqualTo = 0
    LessThan = 1
    LessThanOrEqualTo = 2
    EqualTo = 3
    GreaterThanOrEqualTo = 4
    GreaterThan = 5
End Enum




Public Function ComparisonIsTrue(ByVal sourceValue As Variant, ByVal operator As ComparisonOperator, ByVal comparisonValue As Variant) As Boolean

    If IsNull(sourceValue) Or IsNull(comparisonValue) Then GoTo CleanFail
    If IsObject(sourceValue) Or IsObject(comparisonValue) Then GoTo CleanFail

    Dim isTrue As Boolean

    Select Case operator

        Case NotEqualTo
        isTrue = (sourceValue &lt;&gt; comparisonValue)

        Case LessThan
        isTrue = (sourceValue &lt; comparisonValue)

        Case LessThanOrEqualTo
        isTrue = (sourceValue &lt;= comparisonValue)

        Case EqualTo
        isTrue = (sourceValue = comparisonValue)

        Case GreaterThanOrEqualTo
        isTrue = (sourceValue &gt;= comparisonValue)

        Case GreaterThan
        isTrue = (sourceValue &gt; comparisonValue)

        Case Else
        '/ Error Handling
        Stop

    End Select

CleanExit:
    ComparisonIsTrue = isTrue
    Exit Function

CleanFail:
    isTrue = False
    GoTo CleanExit

End Function
I really don't like your GoTos...

If IsNull(sourceValue) Or IsNull(comparisonValue)
Or IsObject(sourceValue) Or IsObject(comparisonValue) Then
    ComparisonIsTrue = False
    Exit Function
End If


And gone are your gotos.