Dim position As Integer 'selector
position = CInt(txtPosition.Text)
Select Case position
Case 1
txtOutcome.Text = "Win"
Case 2
txtOutcome.Text = "Place"
Case 3
txtOutcome.Text = "Show"
Case 4, 5
txtOutcome.Text = "You almost placed in the money."
Case Else
txtOutcome.Text = "Out of the money."
End Select
End Sub
Friday, February 11, 2011
Case Statements
The following prgram converts the finishing position in a horse race into a descriptive phrase. After the variable position is assigned a value from txtPosition, VB searches for the first Case clause whose value list contains that value and executes the succeeding statement. If the value of position is greater than 5, then the statement following Case Else is executed.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment