J
Joe User
I want to write:
If Left(s,2) = "Mr" Or Left(s,2) = "Ms" Then
...statements...
End If
But that will evaluate both Or operands even if the first one is true.
Is there a more efficient way to implement this?
Note: That example is a simplification. In actual practice, the
conditional expressions are more complicated. So don't try to optimize the
particular example. Optimize the paradigm.
My best:
doit = (Left(s,2) = "Mr")
If Not doit Then doit = (Left(s,2) = "Ms")
If doit Then
...statements...
End If
But that gets a little tedious. Alternatively:
Select Case True
Case Left(s,2) = "Mr", Left(s,2) = "Ms"
...statements....
End Select
But that seems a bit convoluted.
Am I overlooking the obvious?
If Left(s,2) = "Mr" Or Left(s,2) = "Ms" Then
...statements...
End If
But that will evaluate both Or operands even if the first one is true.
Is there a more efficient way to implement this?
Note: That example is a simplification. In actual practice, the
conditional expressions are more complicated. So don't try to optimize the
particular example. Optimize the paradigm.
My best:
doit = (Left(s,2) = "Mr")
If Not doit Then doit = (Left(s,2) = "Ms")
If doit Then
...statements...
End If
But that gets a little tedious. Alternatively:
Select Case True
Case Left(s,2) = "Mr", Left(s,2) = "Ms"
...statements....
End Select
But that seems a bit convoluted.
Am I overlooking the obvious?