Page 157 - Open Soource Technologies 304.indd
P. 157

Unit 6: VB Control Structure























                    Object                Property            Setting

                    frmRace               Text                Horse Race
                    lblPosition           AutoSize            False
                                          Text                Finishing position (1, 2, 3,...):
                    txtPosition
                    btnEvaluate           Text                Evaluate Position
                    txtOutcome            ReadOnly            True


               Private Sub btnEvaluate_Click(...) Handles btnEvaluate.Click
                 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
                    Case  Else
                     txtOutcome.Text = “Out of the money.”
                 End Select
               End Sub
               [Run, type 2 into the text box, and press the button.]




                                      LOVELY PROFESSIONAL UNIVERSITY                        151
   152   153   154   155   156   157   158   159   160   161   162