Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Collections.Generic
- Imports System.ComponentModel
- Imports System.Data
- Imports System.Drawing
- Imports System.Linq
- Imports System.Text
- Imports System.Windows.Forms
- Namespace WindowsFormsApplication1
- Public Partial Class Form1
- Inherits Form
- Private op As Integer = 0, opx As Integer = 0, opd As Integer = 0, opm As Integer = 0, opdeci As Integer = 0, opeq As Integer = 0, _
- equop As Integer = 0
- Private a As Double = 0, b As Double = 0, c As Double = 0
- Public Sub New()
- InitializeComponent()
- End Sub
- Private Sub textBox1_TextChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub button1_Click(sender As Object, e As EventArgs)
- If ansbox.Text.Length > 0 Then
- ansbox.Text = ansbox.Text.Substring(0, ansbox.Text.Length - 1)
- End If
- If ansbox.Text.Length = 0 Then
- ansbox.Text = "0"
- opdeci = 0
- End If
- End Sub
- Private Sub num1_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "1"
- Else
- ansbox.AppendText("1")
- End If
- If op <> 0 Then
- ansbox.Text = "1"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num2_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "2"
- Else
- ansbox.AppendText("2")
- End If
- If op <> 0 Then
- ansbox.Text = "2"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num3_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "3"
- Else
- ansbox.AppendText("3")
- End If
- If op <> 0 Then
- ansbox.Text = "3"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num4_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "4"
- Else
- ansbox.AppendText("4")
- End If
- If op <> 0 Then
- ansbox.Text = "4"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num5_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "5"
- Else
- ansbox.AppendText("5")
- End If
- If op <> 0 Then
- ansbox.Text = "5"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num6_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "6"
- Else
- ansbox.AppendText("6")
- End If
- If op <> 0 Then
- ansbox.Text = "6"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num7_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "7"
- Else
- ansbox.AppendText("7")
- End If
- If op <> 0 Then
- ansbox.Text = "7"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num8_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "8"
- Else
- ansbox.AppendText("8")
- End If
- If op <> 0 Then
- ansbox.Text = "8"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num9_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "9"
- Else
- ansbox.AppendText("9")
- End If
- If op <> 0 Then
- ansbox.Text = "9"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub num0_Click(sender As Object, e As EventArgs)
- If ansbox.Text = "0" Then
- ansbox.Text = "0"
- Else
- ansbox.AppendText("0")
- End If
- If op <> 0 Then
- ansbox.Text = "0"
- op = 0
- opdeci = 0
- End If
- End Sub
- Private Sub button2_Click(sender As Object, e As EventArgs)
- ansbox.Text = "0"
- End Sub
- Private Sub sum_Click(sender As Object, e As EventArgs)
- If equop <> 1 Then
- prodcode()
- divcode()
- If opm = 0 Then
- a += Double.Parse(ansbox.Text)
- Else
- mincode()
- End If
- ansbox.Text = a.ToString()
- op += 1
- End If
- equop = 0
- opeq = 3
- End Sub
- Private Sub prod_Click(sender As Object, e As EventArgs)
- If equop <> 1 Then
- divcode()
- If opx = 0 Then
- b = Double.Parse(ansbox.Text)
- Else
- b = b * Double.Parse(ansbox.Text)
- End If
- op += 1
- End If
- opx = 1
- opeq = 1
- End Sub
- Private Sub button3_Click(sender As Object, e As EventArgs)
- ansbox.Text = "0"
- a = 0
- b = 0
- c = 0
- opx = 0
- op = 0
- opd = 0
- opm = 0
- opdeci = 0
- opeq = 0
- equop = 0
- End Sub
- Private Sub deci_Click(sender As Object, e As EventArgs)
- If opdeci = 0 Then
- If ansbox.Text = "0" Then
- ansbox.Text = "0."
- Else
- ansbox.AppendText(".")
- End If
- If op <> 0 Then
- ansbox.Text = "."
- op = 0
- End If
- End If
- opdeci = 1
- End Sub
- Private Sub div_Click(sender As Object, e As EventArgs)
- If equop <> 1 Then
- prodcode()
- If opd = 0 Then
- c = Double.Parse(ansbox.Text)
- Else
- c = c / Double.Parse(ansbox.Text)
- End If
- op += 1
- End If
- opeq = 2
- opd = 1
- End Sub
- Private Sub min_Click(sender As Object, e As EventArgs)
- If equop <> 1 Then
- prodcode()
- divcode()
- If opm = 0 Then
- a += Double.Parse(ansbox.Text)
- Else
- a -= Double.Parse(ansbox.Text)
- opm = 0
- End If
- ansbox.Text = a.ToString()
- op += 1
- End If
- equop = 0
- opeq = 4
- opm += 1
- End Sub
- Private Sub sqrt_Click(sender As Object, e As EventArgs)
- ansbox.Text = Math.Sqrt(Double.Parse(ansbox.Text)).ToString()
- End Sub
- Private Sub overx_Click(sender As Object, e As EventArgs)
- Dim temp As Double
- temp = Double.Parse(ansbox.Text)
- temp = 1 / temp
- ansbox.Text = temp.ToString()
- End Sub
- Private Sub pom_Click(sender As Object, e As EventArgs)
- ansbox.Text = "-" + ansbox.Text
- End Sub
- Private Sub equals_Click(sender As Object, e As EventArgs)
- Select Case opeq
- Case 1
- If a <> 0 Then
- a = a * Double.Parse(ansbox.Text)
- ansbox.Text = a.ToString()
- Else
- b = b * Double.Parse(ansbox.Text)
- ansbox.Text = b.ToString()
- a = b
- End If
- Exit Select
- Case 2
- If a <> 0 Then
- a = a / Double.Parse(ansbox.Text)
- ansbox.Text = a.ToString()
- Else
- c = c / Double.Parse(ansbox.Text)
- ansbox.Text = c.ToString()
- a = c
- End If
- Exit Select
- Case 3
- a = a + Double.Parse(ansbox.Text)
- ansbox.Text = a.ToString()
- Exit Select
- Case 4
- a = a - Double.Parse(ansbox.Text)
- ansbox.Text = a.ToString()
- Exit Select
- End Select
- op += 1
- equop = 1
- End Sub
- Private Sub prodcode()
- If opx <> 0 Then
- b = b * Double.Parse(ansbox.Text)
- ansbox.Text = b.ToString()
- b = 0
- opx = 0
- End If
- End Sub
- Private Sub divcode()
- If opd <> 0 Then
- c = c / Double.Parse(ansbox.Text)
- ansbox.Text = c.ToString()
- c = 0
- opd = 0
- End If
- End Sub
- Private Sub mincode()
- If opm <> 0 Then
- a -= Double.Parse(ansbox.Text)
- opm = 0
- End If
- End Sub
- End Class
- End Namespace
Add Comment
Please, Sign In to add comment