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

Event Driven Programming



                          Private Sub btnEvaluate_Click(...) Handles btnEvaluate.Click
                            ‘Evaluate answer
                            Dim answer As Double
                            answer = CDbl (txtAnswer.Text)
                            If (answer >= 0.5) And (answer <= 1) Then
                              txtSolution.Text = “Good, “
                           Else
                           txtSolution.Text = “No, “
                            End If
                            txtSolution.Text &= “it holds about 3/4 of a gallon.”
                          End Sub

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




















                          The Else part of an If block can be omitted. This important type of If block appears in the next
                          example.


                                        4: The following program offers assistance to the user before presenting a
                                           quotation.
























                          130                    LOVELY PROFESSIONAL UNIVERSITY
   131   132   133   134   135   136   137   138   139   140   141