The boolean data type is a two-state type that can be either true/false , and True or False can be evaluated as either 1 or 0 in the eyes of the computer (machine language).
When faced to make a choice between 2 variable alternative’s you can only pick one out of the two.
Here’s a sample code evaluating boolean in vb.net
Dim runningVB As Boolean
‘ Check to see if program is running on Visual Basic engine.
If scriptEngine = “VB” Then
runningVB = True
Below is a shorter alternative of the above code using IIf
Dim ScriptEngine As String
Dim runningVB As String = IIf(ScriptEngine =”VB”,”True”,”False”)
The IIf function returns one of two objects, depending on the evaluation of an expression, similar to a boolean expression,it also reduces the lines of code you’ll type, and will allow you evaluate using string data type as well.
Besides the above benefits,there are instances when not to use the IIf function.(e.g when one side of the IIf or the other calls a method that modifies the system state or has output parameters)