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

Unit 6: VB Control Structure


                    Case 7, 8
                     txtPhrase.Text = “Lay them straight.”
                    Case  Else
                     txtPhrase.Text = “Start all over again.”
                 End Select
               End Sub

               [Run, type 4 into the text box, and press the button.]
















               In each of the three preceding examples, the selector was a numeric variable; however, the
               selector also can be a string variable or an expression.


                              4: The following program has the string variable firstName as a selector.



















                     Object                 Property               Setting

                     frmQuiz                Text                   Quiz
                     lblQuestion            AutoSize               False
                                            Text                   What was President Wilson’s
                                                                   first name?
                     txtName

                     btnInterpret           Text                   Interpret Answer
                     txtReply               ReadOnly               True



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