A Simple Application That Demonstrates Simple Calculator 600459– Visual Programming Anna University lab manual download fourth semester - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, January 29, 2011

A Simple Application That Demonstrates Simple Calculator 600459– Visual Programming Anna University lab manual download fourth semester


Aim:

            To develop a simple application that demonstrates simple calculator with control Array


Controls Used:

            Labels
            Textboxes
            Command Buttons


Algorithm:

1.   Start a new project by selecting standard exe from  new project dialog box
  1. Add a textbox and command buttons to the form
  2. Create control array for the command buttons respectively digits on calculator and add necessary coding
  3. Add required coding for other command buttons performing Arithmetic calculation

Source Code:
Option Explicit
Dim n1 As double, n2 As double , flag As string

Private sub cmd_add_click()
n1=txt_disp.Text
txt_disp.Text =  “ “
flag= “+”
End Sub

Private sub cmd_div_click()
n1=txt_disp.Text
txt_disp.Text =  “ “
flag= “/ ”
End Sub

Private sub cmd_mod_click()
n1=txt_disp.Text
txt_disp.Text =  “ “
flag= “ % ”
End Sub

Private sub cmd_mul_click()
n1=txt_disp.Text
txt_disp.Text =   
flag= “ * ”
End Sub

Private Sub cmd_eight_Click()
n2=txt_disp_Text=txt_disp.Text + cmd_eight.Caption
End Sub

Private Sub cmd_equ_Click()
n2=txt_disp.Text
If flag=” + “ Then
txt_disp.Text = n1 + n2
Elseif  flag = “  - “ then
txt_disp.Text = n1 -  n2
Elseif  flag = “  *  “ then
txt_disp.Text = n1 * n2
Elseif  flag = “  / “ then
txt_disp.Text = n1  /  n2
Elseif  flag = “  %“ then
txt_disp.Text = n1 Mod  n2
End If
End Sub

Private Sub cmd_five_Click()
Txt_disp.Text = txt_disp.Text + cmd_five.Caption
End Sub

Private Sub cmd_four_Click()
Txt_disp.Text = txt_disp.Text + cmd_four.Caption
End Sub

Private Sub cmd_one_Click()
Txt_disp.Text = txt_disp.Text + cmd_one.Caption
End Sub

Private Sub cmd_two_Click()
Txt_disp.Text = txt_disp.Text + cmd_two.Caption
End Sub

Private Sub cmd_three_Click()
Txt_disp.Text = txt_disp.Text + cmd_three.Caption
End Sub

Private Sub cmd_six_Click()
Txt_disp.Text = txt_disp.Text + cmd_six.Caption
End Sub

Private Sub cmd_seven_Click()
Txt_disp.Text = txt_disp.Text + cmd_seven.Caption
End Sub

Private Sub cmd_eight_Click()
Txt_disp.Text = txt_disp.Text + cmd_eight.Caption
End Sub

Private Sub cmd_nine_Click()
Txt_disp.Text = txt_disp.Text + cmd_nine.Caption
End Sub

Private Sub cmd_zero_Click()
Txt_disp.Text = txt_disp.Text + cmd_zero.Caption
End Sub

Private Sub cmd_squ_Click()
Txt_disp.Text=txt_disp.Text + cmd_six.Caption
End Sub


No comments:

Post a Comment