0% found this document useful (0 votes)
41 views3 pages

Ex - No: Name: Date: Roll - No:: Building Simple Application (Calculator)

This document describes code for a simple calculator application. It includes variables to store the current and previous values, the selected operation, and the result. Buttons are coded to handle number entry, clear, and operations like add, subtract, multiply and divide. The equal button code uses a select case to evaluate the operation and calculate the result, displaying it and setting it as the current value.

Uploaded by

Babu Parivendan
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
41 views3 pages

Ex - No: Name: Date: Roll - No:: Building Simple Application (Calculator)

This document describes code for a simple calculator application. It includes variables to store the current and previous values, the selected operation, and the result. Buttons are coded to handle number entry, clear, and operations like add, subtract, multiply and divide. The equal button code uses a select case to evaluate the operation and calculate the result, displaying it and setting it as the current value.

Uploaded by

Babu Parivendan
Copyright
© © All Rights Reserved
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

Ex.

No:
BUILDING SIMPLE APPLICATION

(Calculator)
Name :
Date : Roll.No :

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

Private Sub cmd_Click(Index As Integer)
txtDisplay.Text = txtDisplay.Text & cmd(Index).Caption
Current = Val(txtDisplay.Text)
End Sub

Private Sub cmdAC_Click()
Current = Previous = 0
txtDisplay.Text = ""
End Sub

Private Sub cmdDivide_Click()
txtDisplay.Text = ""
Previous = Current
Current = 0
Choice = "/"
End Sub

Private Sub cmdEqual_Click()
Select Case Choice
Case "+"
Result = Previous + Current
txtDisplay.Text = Result
Case "-"
Result = Previous - Current
txtDisplay.Text = Result
Case "*"
Result = Previous * Current
txtDisplay.Text = Result
Case "/"
Result = Previous / Current
txtDisplay.Text = Result
End Select
Current = Result
End Sub

Private Sub cmdMinus_Click()
txtDisplay.Text = ""
Previous = Current
Current = 0
Choice = "-"
End Sub

Private Sub cmdMultiply_Click()
txtDisplay.Text = ""
Previous = Current
Current = 0
Choice = "*"
End Sub

Private Sub cmdNeg_Click()
If txtDisplay.Text = "" Then
txtDisplay.Text = "-"
Else
Current = -Current
txtDisplay.Text = Current
End If
End Sub

Private Sub cmdPlus_Click()
txtDisplay.Text = ""
Previous = Current
Current = 0
Choice = "+"
End Sub
Output Screen Shot:

You might also like