Calculator IN VB.net
Public Class Form1
Dim a, b, c As Double
Dim opr As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "1"
Else
TextBox1.Text = "1"
End If
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "2"
Else
TextBox1.Text = "2"
End If
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "3"
Else
TextBox1.Text = "3"
End If
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "4"
Else
TextBox1.Text = "4"
End If
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "5"
Else
TextBox1.Text = "5"
End If
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "6"
Else
TextBox1.Text = "6"
End If
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "7"
Else
TextBox1.Text = "7"
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "8"
Else
TextBox1.Text = "8"
End If
End Sub
Private Sub Button4_Click_1(sender As Object, e As EventArgs) Handles Button4.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "9"
Else
TextBox1.Text = "9"
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "0"
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "00"
End If
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
NewMethod()
End Sub
Private Sub NewMethod()
If TextBox1.Text <> "." Then
TextBox1.Text += "."
End If
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
a = TextBox1.Text
opr = "+"
TextBox1.Text = ""
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
a = TextBox1.Text
opr = "-"
TextBox1.Text = ""
End Sub
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
a = TextBox1.Text
opr = "*"
TextBox1.Text = ""
End Sub
Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
a = TextBox1.Text
opr = "/"
TextBox1.Text = ""
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
b = TextBox1.Text
If opr = "+" Then
TextBox1.Text = b + a
End If
If opr = "-" Then
TextBox1.Text = a - b
End If
If opr = "*" Then
TextBox1.Text = b * a
End If
If opr = "/" Then
If a <> "0" Then
TextBox1.Text = a / b
Else
TextBox1.Text = ""
End If
End If
End Sub
Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
TextBox1.Text = ""
End Sub
End Class
No comments:
Post a Comment