0% found this document useful (0 votes)
44 views

Q2.) Develop A Simple Calculator Simulating The Simple Tasks Performed by A Calculator. Keep This Calculator Design Very Simple

The document describes a simple calculator program with the following key elements: 1. It includes variables to store the first and second operands, the selected operator, and a status flag. 2. It includes click event procedures for the number buttons 0-9 that append the number to the output text or set the output depending on the status flag. 3. It includes procedures for the clear, clear entry, and operator buttons that set operands and operators as needed to perform calculations. 4. The equal button procedure selects the operator and performs the calculation, outputting the result and resetting operands and status.

Uploaded by

Arpit_Mehta_9827
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Q2.) Develop A Simple Calculator Simulating The Simple Tasks Performed by A Calculator. Keep This Calculator Design Very Simple

The document describes a simple calculator program with the following key elements: 1. It includes variables to store the first and second operands, the selected operator, and a status flag. 2. It includes click event procedures for the number buttons 0-9 that append the number to the output text or set the output depending on the status flag. 3. It includes procedures for the clear, clear entry, and operator buttons that set operands and operators as needed to perform calculations. 4. The equal button procedure selects the operator and performs the calculation, outputting the result and resetting operands and status.

Uploaded by

Arpit_Mehta_9827
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Q2.

)Develop a simple calculator simulating the simple tasks performed


by a calculator. Keep this calculator design very simple.
Commanding
Dim operand1 As Double
Dim operand2 As Double
Dim operator As String
Dim status As Boolean

Private Sub cmd0_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "0"
Else
txtoutput.Text = "0"
status = True
End If
End Sub

Private Sub cmd1_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "1"
Else
txtoutput.Text = "1"
status = True
End If
End Sub

Private Sub cmd2_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "2"
Else
txtoutput.Text = "2"
status = True
End If
End Sub

Private Sub cmd3_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "3"
Else
txtoutput.Text = "3"
status = True
End If
End Sub

Private Sub cmd4_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "4"
Else
txtoutput.Text = "4"
status = True
End If
End Sub

Private Sub cmd5_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "5"
Else
txtoutput.Text = "5"
status = True
End If
End Sub

Private Sub cmd6_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "6"
Else
txtoutput.Text = "6"
status = True
End If
End Sub

Private Sub cmd7_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "7"
Else
txtoutput.Text = "7"
status = True
End If
End Sub

Private Sub cmd8_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "8"
Else
txtoutput.Text = "8"
status = True
End If
End Sub
Private Sub cmd9_Click()
If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "9"
Else
txtoutput.Text = "9"
status = True
End If
End Sub

Private Sub cmdC_Click()


txtoutput.Text = "0"
operand1 = 0
operand2 = 0
End Sub

Private Sub cmdCE_Click()


txtoutput.Text = "0"
operand2 = 0
End Sub

Private Sub cmddivide_Click()


operand1 = Val(txtoutput.Text)
txtoutput.Text = "/"
operator = "/"
End Sub

Private Sub cmddot_Click()


If Val(txtoutput.Text) <> Andstatus = True Then
txtoutput.Text = txtoutput.Text + "."
Else
txtoutput.Text = "."
status = True
End If
End Sub

Private Sub cmdequal_Click()


operand2 = txtoutput.Text
Select Case perator
Case "+"
txtoutput.Text = operand1 + operand2
Case "-"
txtoutput.Text = operand1 - operand2
Case "*"
txtoutput.Text = operand1 * operand2
Case "/"
If operand2 = 0 Then
MsgBox ("Divide by zero error")
txtoutput.Text = "0"
Else
txtoutput.Text = operand1 / operand2
End If
End Select
operand1 = 0
operand2 = 0
status = False
End Sub

Private Sub cmdminus_Click()


operand1 = Val(txtoutput.Text)
txtoutput.Text = "-"
operator = "-"
End Sub

Private Sub cmdmultiply_Click()


operand1 = Val(txtoutput.Text)
txtoutput.Text = "*"
operator = "*"
End Sub

Private Sub cmdpercent_Click()


txtoutput.Text = Val(txtoutput.Text) / 100
End Sub

Private Sub cmdplus_Click()


operand1 = Val(txtoutput.Text)
txtoutput.Text = "+"
operator = "+"
End Sub

Private Sub Form_Load()


status = False
End Sub

You might also like