This document describes the design of a basic calculator application. It defines variables to store the first number, second number, answer, and operation. It includes event handler subroutines for each of the number and operator buttons that update the text box display. The equal button subroutine evaluates the calculation based on the stored operation and numbers, and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
46 views
Calculator Design: Form1
This document describes the design of a basic calculator application. It defines variables to store the first number, second number, answer, and operation. It includes event handler subroutines for each of the number and operator buttons that update the text box display. The equal button subroutine evaluates the calculation based on the stored operation and numbers, and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
CALCULATOR DESIGN
Public Class Form1
Dim FirstNumber As Integer Dim SecondNumber As Integer Dim AnswerNumber As Double Dim ArithmeticProcess As String Private Sub btnone_Click(sender As Object, e As EventArgs) Handles btnone.Click txtBox.Text = txtBox.Text & btnone.Text End Sub
Private Sub btntwo_Click(sender As Object, e As EventArgs) Handles btntwo.Click
txtBox.Text = txtBox.Text & btntwo.Text End Sub
Private Sub btnthree_Click(sender As Object, e As EventArgs) Handles btnthree.Click
txtBox.Text = txtBox.Text & btnthree.Text End Sub
Private Sub btnfour_Click(sender As Object, e As EventArgs) Handles btnfour.Click
txtBox.Text = txtBox.Text & btnfour.Text End Sub
Private Sub btnfive_Click(sender As Object, e As EventArgs) Handles btnfive.Click
txtBox.Text = txtBox.Text & btnfive.Text End Sub
Private Sub btnsix_Click(sender As Object, e As EventArgs) Handles btnsix.Click
txtBox.Text = txtBox.Text & btnsix.Text End Sub
Private Sub btnseven_Click(sender As Object, e As EventArgs) Handles btnseven.Click
txtBox.Text = txtBox.Text & btnseven.Text End Sub
Private Sub btneight_Click(sender As Object, e As EventArgs) Handles btneight.Click
txtBox.Text = txtBox.Text & btneight.Text End Sub
Private Sub btnnine_Click(sender As Object, e As EventArgs) Handles btnnine.Click
txtBox.Text = txtBox.Text & btnnine.Text End Sub
Private Sub btnzero_Click(sender As Object, e As EventArgs) Handles btnzero.Click
txtBox.Text = txtBox.Text & btnzero.Text End Sub
Private Sub btnplus_Click(sender As Object, e As EventArgs) Handles btnplus.Click
Private Sub btnminus_Click(sender As Object, e As EventArgs) Handles btnminus.Click
FirstNumber = Val(txtBox.Text) txtBox.Text = "" ArithmeticProcess = "-" End Sub
Private Sub btndivide_Click(sender As Object, e As EventArgs) Handles btndivide.Click
FirstNumber = Val(txtBox.Text) txtBox.Text = "" ArithmeticProcess = "/" End Sub
Private Sub btnequal_Click(sender As Object, e As EventArgs) Handles btnequal.Click
SecondNumber = Val(txtBox.Text) If ArithmeticProcess = "+" Then AnswerNumber = FirstNumber + SecondNumber ElseIf ArithmeticProcess = "-" Then AnswerNumber = FirstNumber - SecondNumber ElseIf ArithmeticProcess = "X" Then AnswerNumber = FirstNumber * SecondNumber ElseIf ArithmeticProcess = "/" Then If SecondNumber = 0 Then MsgBox(" any number divided by zero is not defined") Else AnswerNumber = FirstNumber / SecondNumber End If
End If txtBox.Text = AnswerNumber
End Sub
Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
txtBox.Text = ""
End Sub
Private Sub btntimes_Click(sender As Object, e As EventArgs) Handles btntimes.Click
FirstNumber = Val(txtBox.Text) txtBox.Text = "" ArithmeticProcess = "X" End Sub End Class