Condition and Alternative (If... Else... End If)

If construct to branch into two different blocks of code.

 

If Parameter1 = 10 Then

   DoAny := 10

Else

   DoAny := 100

End If

The DoAny variable is given a value of 10 if parameter1 is 10, otherwise the value is 100

The inline if (IIf) can also be used in common either/or decisions (e.g. in expressions of forms or controls).

 

Dim Result As Long

Result := IIf(Test = True, 10, 20)

The first parameter is the condition to be checked for truth. The second parameter is the return value of the function in case of truth, the third parameter is the return value in case of untruth.