Page 437 - Computer Software Application TP - Volume 1
P. 437

COMPUTER SOFTWARE APPLICATION - CITS




           Property Box
              S. No.            Control                Property                  Value

                 1      CommndButton1                   Name                  cmdsolution

                                                        Caption                 Solution
                 2      CommandButton2                  Name                   cmdclear
                                                        Caption                  Clear

           Step 3: Double click on the Clear button and write down the following code:

           Private Sub cmdclear_Click()
           Range(“B2:B9,A6:A8”) = “ “
           End Sub
           Step 4: Double click on the Solution button and write down the following code:
           Private Sub cmdsolution_Click()

           Dim a As Integer, b As Integer, c As Integer
           Dim d As Single, root1 As Single, root2 As Single
           a = InputBox(“Enter the value of a”)
           b = InputBox(“Enter the value of b”)

           c = InputBox(“Enter the value of c”)
           Range(“B2”) = a
           Range(“B3”) = b
           Range(“B4”) = c
           d = b * b - 4 * a * c
           Range(“A6”) = “Discriminent”

           Range(“B6”) = Round(d, 2)
           If d = 0 Then
           root1 = -b / (2 * a)
           Range(“A7”) = “Root is “

           Range(“B7”) = Round(root1, 2)
           Range(“B9”) = “ Roots are real and Equal”
           ElseIf d > 0 Then
           root1 = (-b + Sqr(d)) / (2 * a)
           root2 = (-b - Sqr(d)) / (2 * a)

           Range(“A7”) = “Root1 is “
           Range(“B7”) = Round(root1, 2)
           Range(“A8”) = “Root2 is “
           Range(“B8”) = Round(root2, 2)
           Range(“B9”) = “ Roots are real and UnEqual”

           Else
           Range(“B9”) = “ Roots are imaginary”



                                                           422
                                CITS : IT & ITES - Computer Software Application - Exercise 70
   432   433   434   435   436   437   438   439   440   441   442