15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Branching Statements 599<br />

The preceding SELECT-CASE is equivalent to the following IF-THEN-ELSEIF<br />

statement:<br />

Book VI<br />

Chapter 5<br />

IF variable = value1 THEN<br />

Command<br />

ELSEIF variable = value2 THEN<br />

Command<br />

ELSEIF variable = value3 THEN<br />

Command<br />

END IF<br />

Visual Basic and<br />

REALbasic<br />

To check if a variable matches multiple values, you can separate multiple values<br />

with commas or use the TO keyword to match a range of values, such as<br />

SELECT CASE variable<br />

CASE value1, value2, value3<br />

Command<br />

CASE value4 TO value10<br />

Command<br />

END SELECT<br />

The preceding SELECT-CASE is equivalent to the following IF-THEN-ELSEIF<br />

statement:<br />

IF variable = value1 OR variable = value2 OR variable =<br />

value3 THEN<br />

Command<br />

ELSEIF variable >= value4 AND variable = value1<br />

Command<br />

CASE IS < value2<br />

Command<br />

END SELECT<br />

When the SELECT-CASE statement uses comparison operators, it uses the<br />

IS keyword.<br />

The preceding SELECT-CASE statement is equivalent to<br />

IF variable >= value1 THEN<br />

Command<br />

ELSEIF variable < value2 THEN<br />

Command<br />

END IF

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!