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

Event Driven Programming



                          Dim varName As String

                                        1:  The following program computes the sum of two numbers supplied by the user:















                                            Object                 Property                 Setting

                                            frmAdd                 Text                     Addition
                                            lblFirstNum            AutoSize                 False
                                            Text                   First Number:
                                            txFirstNum
                                            lblSecondNum           AutoSize                 False
                                            Text                   Second Number:
                                            btnCompute             Text                     Compute Sum
                                            txtSecondNum
                                            lblSum                 Text                     Sum:
                                            txtSum                 ReadOnly                 True

                                        Private Sub btnCompute_Click() Handles btnCompute.Click
                                        Dim num1, num2, sum As Double
                                        num1 = CDbl(txtFirstNum.Text)
                                        num2 = CDbl(txtSecondNum.Text)
                                        sum = num1 + num2
                                        txtSum.Text = CStr(sum)
                                        End Sub
                                        [Run, type 45 into the first text box, type 55 into the second text box, and click on
                                        the button.]

















                          94                     LOVELY PROFESSIONAL UNIVERSITY
   95   96   97   98   99   100   101   102   103   104   105