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

Event Driven Programming


                          Private Sub btnInterpret_Click(...) Handles btnInterpret.Click
                            ‘Quiz
                            Dim firstName As String
                            firstName = txtName.Text.ToUpper
                            Select Case  firstName
                               Case “THOMAS”
                                txtReply.Text = “Correct.”
                               Case  “WOODROW”
                                txtReply.Text = “Sorry, his full name was “ & _
                                                “Thomas Woodrow Wilson.”
                               Case “PRESIDENT”
                                txtReply.Text = “Are you for real?”
                               Case  Else
                                txtReply.Text = “Nice try, but no cigar.”
                            End Select
                          End Sub
                           [Run, type “Woodrow” into the text box, and press the button.]



















                                        5: The following program has the string selector anyString.Substring (0, 1). In
                                           the sample run, only the first action was carried out, even though the value
                                           of the selector was in both of the first two value lists. Visual Basic stops
                                           looking as soon as it finds the value of the selector.




















                          156                    LOVELY PROFESSIONAL UNIVERSITY
   157   158   159   160   161   162   163   164   165   166   167