Chapter 17 The Dual-Alternative Decision Structure

17.1 The Dual-Alternative Decision Structure

In contrast to the single-alternative decision structure, this type of decision control structure includes a statement or block of statements on both paths.

Image

If Boolean_Expression evaluates to True, the statement or block of statements 1 is executed; otherwise, the statement or block of statements 2 is executed.

The general form of the Visual Basic statement is

If Boolean_Expression Then
A statement or block of statements 1
Else
A statement or block of statements 2
End If

In the next example, the message “You are an adult” is displayed when the user ...

Get Visual Basic and Algorithmic Thinking for the Complete Beginner now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.