0% found this document useful (0 votes)
33 views2 pages

Form1: Public Class Dim As Double

This document contains the code for a basic calculator application with the following functionality: - Buttons to input numbers and operators and display the calculation in a text box - A button to clear the text box - A button to delete the last character entered - A button to change the sign of the displayed number - Logic to evaluate simple addition, subtraction, multiplication and division calculations based on the entered numbers and operator
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Form1: Public Class Dim As Double

This document contains the code for a basic calculator application with the following functionality: - Buttons to input numbers and operators and display the calculation in a text box - A button to clear the text box - A button to delete the last character entered - A button to change the sign of the displayed number - Logic to evaluate simple addition, subtraction, multiplication and division calculations based on the entered numbers and operator
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form1

Dim op1, op2 As Double

Dim ope As Char

Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button15.Click,


Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click,
Button7.Click, Button8.Click, Button9.Click
Dim btn As Button
btn = CType(sender, Button)
TextBox1.Text = TextBox1.Text & btn.Text

End Sub

Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click,


Button13.Click, Button12.Click, Button11.Click
Dim btn As Button
btn = CType(sender, Button)
ope = btn.Text

op1 = TextBox1.Text

TextBox1.Clear()

End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click

op2 = TextBox1.Text
If ope = "+" Then
TextBox1.Text = op1 + op2
ElseIf ope = "-" Then
TextBox1.Text = op1 - op2

ElseIf ope = "*" Then


TextBox1.Text = op1 * op2
ElseIf ope = "/" Then
TextBox1.Text = op1 / op2

End If

End Sub

Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click


TextBox1.Clear()

End Sub

Private Sub Button17_Click_1(sender As Object, e As EventArgs) Handles Button17.Click

If TextBox1.Text < " " Then


TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1 + 1)
Else
TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1)
End If
End Sub

Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click


If TextBox1.Text <> 0 Then
TextBox1.Text = -TextBox1.Text
Else

TextBox1.Text = "-"
End If
End Sub
End Class

You might also like