Fandom

Visual Basic Wiki

IIf

70pages on
this wiki
Add New Page
Talk0 Share

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.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.