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

Unit 6: VB Control Structure



                      Object            Property       Setting

                      frmAnalyze        Text           Analyze First Character of a String
                      lblEnter          Text           Enter a string:
                      txtString
                      btnAnalyze        Text           Analyze
                      txtResult         ReadOnly       True

               Private Sub btnAnalyze_Click(...) Handles btnAnalyze.Click
                 ‘Analyze the first character of a string
                 Dim anyString As String
                 anyString = txtString.Text.ToUpper
                   Select case anyString.Substring(0, 1)
                    Case “S”, “Z”
                     txtResult.Text = “The string begins with a sibilant.”
                    Case “A” To “Z”
                         txtResult.Text = “The string begins with a nonsibilant.”
                 Case “0” To “9”
                     txtResult.Text = “The string begins with a digit.”
                   Case Is < “0”
                     txtResult.Text = “The string begins with a character of “ & _
                                  “ANSI value less than 48.”
                   Case Else
                     txtResult.Text = “The string begins with :  ;  <  =  > “ &_
                               “ ?  @  [  \  ]  ^  _  or ‘  .“
                 End Select
                   End Sub

                [Run, type “Sunday” into the text box, and press the button.]

























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