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

Unit 7: Arrays in Visual Basic



                    CommandButton           Caption                 AC
                                            Name                    cmdAC

                    CommandButton           Caption                 +
                                            Name                    cmdPlus

                    CommandButton           Caption                 –
                                            Name                    cmdMinus

                    CommandButton           Caption                 *
                                            Name                    cmdMultiply
                    CommandButton           Caption                 /
                                            Name                    cmdDivide
                    CommandButton           Caption                 +/-
                                            Name                    cmdNeg
                    TextBox                 Name                    txtDisplay
                                            Text                    ( empty )
                    CommandButton           Caption                 =
                                            Name                    cmdEqual



















               The following variables are declared inside the general declaration

               Dim Current As Double
               Dim Previous As Double
               Dim Choice As String
               Dim Result As Double

               The following code is entered in the cmd_Click( ) (Control Array) event procedure
               Private Sub cmd_Click(Index As Integer)
               txtDisplay.Text = txtDisplay.Text & cmd(Index).Caption
               ’&is the concatenation operator
               Current = Val(txtDisplay.Text)


                                      LOVELY PROFESSIONAL UNIVERSITY                        175
   176   177   178   179   180   181   182   183   184   185   186