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

Event Driven Programming



                          11:  Add code to handle the C and CE buttons. C clears all input to the calculator, whereas CE
                          only clears the number currently being entered.
                          Private Sub btnC_Click()
                          sLeft = “”
                          sRight = “”

                          sOperator = “”
                          tbResult.Text = “0”
                          bLeft = True
                          End Sub

                          Private Sub btnCE_Click()
                          If bLeft Then
                          sLeft = “”
                          Else
                          sRight = “”
                          End If

                          tbResult.Text = “0”
                          End Sub
                          12:
























                                              Fig. 14.11:  Completed calculator in action (ALLD)


                                        If buttons and textbox are not named the same as the code expects, it will need
                                        to change the names to match buttons and textbox, or change buttons and
                                        textbox to match this code.




                          312                    LOVELY PROFESSIONAL UNIVERSITY
   313   314   315   316   317   318   319   320   321   322   323