Thread: IIf
View Single Post
Old June 21st, 2007, 12:24 AM
woodyz woodyz is offline
Friend of Wrox
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

Well... actually, the value of the immediate if (IIf) is for use in an expression or as an argument being passed to a parameter of a procedure.

Note that IIf itself is a function which accepts 3 parameters and returns a value. Although it seems as if it is the same thing as a regular If...Else block, its real benefit is that it returns a value. Each argument itself can also be an expression, and this brings a great deal of power to this little intrinsic function. However, make sure all the arguments will be valid in all cases because all three arguments must be resolved before they are passed on to the IIf function, just like with any other function. In other words, regardless if the first argument is true or false, both the 2nd and 3rd arguments are going to be processed before their values are passed into the function.

Woody Z
How to use a forum to help solve problems