And just to beat this point into the ground, the new operator is better than your IIf function because a function will evaluate both parameters whereas the new operator will only evaluate the “correct” parameter.
For example, this code would quit your app:
status = IIf( true, SomeFunction, FunctionThatAlsoQuitsTheApp ) // Calls IIf method
This won’t:
status = If( true, SomeFunction, FunctionThatAlsoQuitsTheApp ) // Uses new If operator
Also better because it doesn’t use variants and is statically typed.
Cool… This reminds me of C/C++
x = (a > b) ? 1 : 2;
And, btw.: It seems to be a bit faster than a conservative if
then
else method.
Not much, but I tested a nonsense-loop, once in an if
then condition, once with the if operator. Came out thus:
[code]10000 iterations:
1374.769 Microseconds on first loop
1135.021 Microseconds on second loop
1000000 iterations:
137856.2 Microseconds on first loop
111309.8 Microseconds on second loop
[/code]