Campbell Scientific CR9000X Measurement and Control System User Manual

Page 348

Advertising
background image

Section 9. Program Control Instructions

The argument expression list has these parts:
Part Description

expression Any numeric expression.

To

Keyword used to specify a range of values. If you use the To
keyword to indicate a range of values, the smaller value must
precede To.

Although not required, it is a good idea to have a Case Else
statement in your Select Case block to handle unforeseen
testexpression values.

NOTE

You can use multiple expressions or ranges in each Case clause. For example,
the following line is valid:

Case 1 To 4, 7 To 9, 11, 13

Select Case statements can be nested. Each Select Case statement must have a
matching End Select statement.

Select Case Statement Example
The example uses Select Case to decide what action to take based on user
input.

Dim X, Y

'Declare variables.

If Not X = Y Then

'Are they equal

If X > Y Then

SELECT CASE

X

'What is X.

CASE

0 To 9

'Must be less than 10.

.

. . .

'Run some code.

.

. . .

'Run some code.

CASE

10 To 99

'Must be less than 100.

.

. . .

'Run some code.

.

. . .

'Run some code.

CASE ELSE

Must be something else.

. . . .

'Run some code.

END SELECT

END IF
ELSE
SELECT CASE

Y

'What is Y.

CASE

1, 3, 5, 7, 9

'It's odd.

.

. . .

'Run some code.

CASE

0, 2, 4, 6, 8

'It's even.

.

. . .

'Run some code.

CASE ELSE

'Out of range.

. . . .

'Run some code.

. . . .

'Run some code.

END SELECT

END IF

9-18

Advertising