Immediate IF (IIF)

You can use the Immediate IF function if you want.
This function will always evaluate both the true and false parts even though it only returns one. IIF(expression, truepart, falsepart).
VBA does offer an alternative to the If-Then-Else construct IIF(expr,truepart,falsepart), although very few people use it.
An experienced programmer would never use Immediate IF.

IIF(expression, statement if true, statement if false) 

Dim iNumber As Integer 
iNumber = 50
Call Msgbox( IIf( iNumber > 40, "over forty", "less than forty") )

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext