<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - IIf
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="if+en">Previous</a>&nbsp;
<a href="in+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
IIf
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Value</u> <b>= IIf (</b> <u>bTest</u> AS Boolean <b>,</b> <u>vTrue</u> [ <b>,</b> <u>vFalse</u> ] <b>)</b>
<u>Value</u> <b>= If (</b> <u>bTest</u> AS Boolean <b>,</b> <u>vTrue</u> [ <b>,</b> <u>vFalse</u> ] <b>)</b></pre><p>

Evaluate the <u>bTest</u> expression, and return <u>vTrue</u>  if this expression is <a href="true+en">TRUE</a>,
or <u>vFalse</u> if this expression is <a href="false+en">FALSE</a>.
<p>
If <u>vFalse</u> is not specified, it is assumed to be <a href="null+en">NULL</a>.
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
Be careful! Contrary to <a href="if+en">IF</a>, or the C/Perl <tt>?</tt> operator, both <u>vTrue</u> and <u>vFalse  are evaluated, whatever the value of </u>bTest<u> is.
</td></tr></table></div>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">X = 7
PRINT If((X MOD 2) = 0, &quot;even&quot;, &quot;odd&quot;)
<hr>odd</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">' Never do the following in real code, because it is not translatable!
X = 7
PRINT &quot;You have &quot; & X & &quot; message&quot; & If(X <> 1, &quot;s&quot;) & &quot; waiting.&quot;
<hr>You have 7 messages waiting.</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT If((X MOD 2) = 1, &quot;odd&quot;, 1 / 0)
<hr>Division by zero</pre>
<p>
<hr><b>See also</b><br>
<a href="../cat/test+en">Test Control Structures &amp; Functions</a>&nbsp;

</div>
</body>
</html>

