Function: IIf Edit

IIf makes conditional statements terser. PHP comparison to VB:

// PHP
$data = $expr ? truePart : falsePart
' VB
Data = IIf(expr, truePart, falsePart)

Usage Edit

IIf(Expression, TruePart, FalsePart)

Howto Edit

If expression is true TruePart is returned, otherwise FalsePart is returned

Iif(a>0,kk=1,kk=2) Edit

Notes Edit

If you put calls to functions in the True or False parts those functions will be called even if the results of that function are not returned by the condition. The IIf is a function and all parts are evaluated first and then the results are passed to the IIf. Based on the conditional expression the result of either the true or the false part is returned.

In VB.NET this function returns an Object type and if you have option strict turned on, you will need to convert the results to the actual type of the variable you are trying to put the data into.