Page 158 - Open Soource Technologies 304.indd
P. 158
Event Driven Programming
2: In the following variation of Example, the value lists specify ranges of
values. The first value list provides another way to stipulate the numbers
1, 2, and 3. The second value list covers all numbers from 4 on.
Private Sub btnEvaluate_Click(...) Handles btnEvaluate.Click
‘Describe finishing positions in a horse race
Dim position As Integer
position = CInt(txtPosition.Text)
Select Case position
Case 1 To 3
txtOutcome.Text = “In the money. Congratulations.”
Case Is >= 4
txtOutcome.Text = “Not in the money.”
End Select
End Sub
[Run, type 2 into the text box, and press the button.]
A typical form of the Select Case block is
Select Case selector
Case valueList1
152 LOVELY PROFESSIONAL UNIVERSITY