Chapter 19 The Case Decision Structure

19.1 The Case Decision Structure

The case decision structure is a simplified version of the multiple-alternative decision structure. It helps you write code faster and increases readability, especially for algorithms that require complex combinations of decision structures. The case decision structure is used to expand the number of alternatives in the same way as the multiple-alternative decision structure does.

The general form of the Visual Basic statement is

Select Case a_variable_or_an_expression_to_evaluate
Case expression-1
A statement or block of statements 1
Case expression-2
A statement or block of statements 2
Case expression-3
A statement or block of statements 3
.
.
.
Case expression-N
A statement ...

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.