Table of Contents

10.2.2 Two-sided selection IFF

Syntax for 2nd variant of the two-sided, alternative selection:

Value = IIf ( Test AS Boolean , TrueExpression , FalseExpression ) 
Value = If ( Test AS Boolean , TrueExpression , FalseExpression ) 

The test expression is evaluated and returns TrueExpression if the expression is TRUE or FalseExpression if the expression is FALSE.

10.2.2.2.1 Example 1

iNumber = 7 
LabelIIF.Text = IIF((iNumber MOD 2) = 0, "N is an even number", "N is an odd number.") 

The text “N is an odd number” is set as label text for iNumber = 7.

10.2.2.2.2 Example 2

In the second example 2 panels are used alternatively in a project to display the graphs of the program' GnuPlot'. First the current (display) panel is determined and then the labeling of the toggle buttons - depending on the current panel - is set:

Public Sub togWhich_Click() 
  $hCurrentPanel = IIF($hCurrentPanel = panPanel1, panPanel2, panPanel1) 
  togWhich.Text = IIF($hCurrentPanel = panPanel1, ("Use lower Panel"), ("Use upper Panel"))
  Print #$hGnuplot, Subst$("set terminal x11 window \"&1\"", Hex$($hPanel.Handle)) 
End ' togWhich_Click() 

Hints:

Download