Chapter 16 The Single-Alternative Decision Structure

16.1 The Single-Alternative Decision Structure

This is the simplest decision control structure. It includes a statement or block of statements on the “True” path only, as presented in the following flowchart fragment, given in general form.

Image

If Boolean_Expression evaluates to True, the statement, or block of statements, of the structure is executed; otherwise, the statements are skipped.

The general form of the Visual Basic statement is

If Boolean_Expression Then
A statement or block of statements
End If

Note that the statement or block of statements is indented by 2 spaces.

In the next example, ...

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.