Guest User

Untitled

a guest
Jun 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Collections.Generic
  2. Imports System.ComponentModel
  3. Imports System.Data
  4. Imports System.Drawing
  5. Imports System.Linq
  6. Imports System.Text
  7. Imports System.Windows.Forms
  8.  
  9.  
  10. Namespace WindowsFormsApplication1
  11.  
  12.  
  13.     Public Partial Class Form1
  14.         Inherits Form
  15.         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, _
  16.             equop As Integer = 0
  17.  
  18.         Private a As Double = 0, b As Double = 0, c As Double = 0
  19.  
  20.         Public Sub New()
  21.             InitializeComponent()
  22.         End Sub
  23.  
  24.         Private Sub textBox1_TextChanged(sender As Object, e As EventArgs)
  25.  
  26.         End Sub
  27.  
  28.         Private Sub button1_Click(sender As Object, e As EventArgs)
  29.  
  30.             If ansbox.Text.Length > 0 Then
  31.                 ansbox.Text = ansbox.Text.Substring(0, ansbox.Text.Length - 1)
  32.             End If
  33.             If ansbox.Text.Length = 0 Then
  34.                 ansbox.Text = "0"
  35.                 opdeci = 0
  36.             End If
  37.  
  38.         End Sub
  39.  
  40.         Private Sub num1_Click(sender As Object, e As EventArgs)
  41.             If ansbox.Text = "0" Then
  42.                 ansbox.Text = "1"
  43.             Else
  44.                 ansbox.AppendText("1")
  45.             End If
  46.  
  47.             If op <> 0 Then
  48.                 ansbox.Text = "1"
  49.                 op = 0
  50.                 opdeci = 0
  51.             End If
  52.  
  53.  
  54.         End Sub
  55.  
  56.         Private Sub num2_Click(sender As Object, e As EventArgs)
  57.             If ansbox.Text = "0" Then
  58.                 ansbox.Text = "2"
  59.             Else
  60.                 ansbox.AppendText("2")
  61.             End If
  62.  
  63.             If op <> 0 Then
  64.                 ansbox.Text = "2"
  65.                 op = 0
  66.                 opdeci = 0
  67.             End If
  68.         End Sub
  69.  
  70.         Private Sub num3_Click(sender As Object, e As EventArgs)
  71.             If ansbox.Text = "0" Then
  72.                 ansbox.Text = "3"
  73.             Else
  74.                 ansbox.AppendText("3")
  75.             End If
  76.  
  77.             If op <> 0 Then
  78.                 ansbox.Text = "3"
  79.                 op = 0
  80.                 opdeci = 0
  81.             End If
  82.         End Sub
  83.  
  84.         Private Sub num4_Click(sender As Object, e As EventArgs)
  85.             If ansbox.Text = "0" Then
  86.                 ansbox.Text = "4"
  87.             Else
  88.                 ansbox.AppendText("4")
  89.             End If
  90.  
  91.             If op <> 0 Then
  92.                 ansbox.Text = "4"
  93.                 op = 0
  94.                 opdeci = 0
  95.             End If
  96.         End Sub
  97.  
  98.         Private Sub num5_Click(sender As Object, e As EventArgs)
  99.             If ansbox.Text = "0" Then
  100.                 ansbox.Text = "5"
  101.             Else
  102.                 ansbox.AppendText("5")
  103.             End If
  104.  
  105.             If op <> 0 Then
  106.                 ansbox.Text = "5"
  107.                 op = 0
  108.                 opdeci = 0
  109.             End If
  110.         End Sub
  111.  
  112.         Private Sub num6_Click(sender As Object, e As EventArgs)
  113.             If ansbox.Text = "0" Then
  114.                 ansbox.Text = "6"
  115.             Else
  116.                 ansbox.AppendText("6")
  117.             End If
  118.  
  119.             If op <> 0 Then
  120.                 ansbox.Text = "6"
  121.                 op = 0
  122.                 opdeci = 0
  123.             End If
  124.         End Sub
  125.  
  126.         Private Sub num7_Click(sender As Object, e As EventArgs)
  127.             If ansbox.Text = "0" Then
  128.                 ansbox.Text = "7"
  129.             Else
  130.                 ansbox.AppendText("7")
  131.             End If
  132.  
  133.             If op <> 0 Then
  134.                 ansbox.Text = "7"
  135.                 op = 0
  136.                 opdeci = 0
  137.             End If
  138.         End Sub
  139.  
  140.         Private Sub num8_Click(sender As Object, e As EventArgs)
  141.             If ansbox.Text = "0" Then
  142.                 ansbox.Text = "8"
  143.             Else
  144.                 ansbox.AppendText("8")
  145.             End If
  146.  
  147.             If op <> 0 Then
  148.                 ansbox.Text = "8"
  149.                 op = 0
  150.                 opdeci = 0
  151.             End If
  152.         End Sub
  153.  
  154.         Private Sub num9_Click(sender As Object, e As EventArgs)
  155.             If ansbox.Text = "0" Then
  156.                 ansbox.Text = "9"
  157.             Else
  158.                 ansbox.AppendText("9")
  159.             End If
  160.  
  161.             If op <> 0 Then
  162.                 ansbox.Text = "9"
  163.                 op = 0
  164.                 opdeci = 0
  165.             End If
  166.         End Sub
  167.  
  168.         Private Sub num0_Click(sender As Object, e As EventArgs)
  169.             If ansbox.Text = "0" Then
  170.                 ansbox.Text = "0"
  171.             Else
  172.                 ansbox.AppendText("0")
  173.             End If
  174.  
  175.             If op <> 0 Then
  176.                 ansbox.Text = "0"
  177.                 op = 0
  178.                 opdeci = 0
  179.             End If
  180.         End Sub
  181.  
  182.         Private Sub button2_Click(sender As Object, e As EventArgs)
  183.             ansbox.Text = "0"
  184.  
  185.         End Sub
  186.  
  187.         Private Sub sum_Click(sender As Object, e As EventArgs)
  188.  
  189.             If equop <> 1 Then
  190.                 prodcode()
  191.                 divcode()
  192.                 If opm = 0 Then
  193.                     a += Double.Parse(ansbox.Text)
  194.                 Else
  195.                     mincode()
  196.                 End If
  197.  
  198.                 ansbox.Text = a.ToString()
  199.  
  200.                 op += 1
  201.             End If
  202.             equop = 0
  203.             opeq = 3
  204.         End Sub
  205.  
  206.         Private Sub prod_Click(sender As Object, e As EventArgs)
  207.             If equop <> 1 Then
  208.                 divcode()
  209.                 If opx = 0 Then
  210.                     b = Double.Parse(ansbox.Text)
  211.                 Else
  212.                     b = b * Double.Parse(ansbox.Text)
  213.                 End If
  214.  
  215.  
  216.                 op += 1
  217.             End If
  218.             opx = 1
  219.             opeq = 1
  220.         End Sub
  221.  
  222.         Private Sub button3_Click(sender As Object, e As EventArgs)
  223.             ansbox.Text = "0"
  224.             a = 0
  225.             b = 0
  226.             c = 0
  227.             opx = 0
  228.             op = 0
  229.             opd = 0
  230.             opm = 0
  231.             opdeci = 0
  232.             opeq = 0
  233.             equop = 0
  234.         End Sub
  235.  
  236.         Private Sub deci_Click(sender As Object, e As EventArgs)
  237.             If opdeci = 0 Then
  238.                 If ansbox.Text = "0" Then
  239.                     ansbox.Text = "0."
  240.                 Else
  241.                     ansbox.AppendText(".")
  242.                 End If
  243.  
  244.                 If op <> 0 Then
  245.                     ansbox.Text = "."
  246.                     op = 0
  247.                 End If
  248.             End If
  249.             opdeci = 1
  250.         End Sub
  251.  
  252.  
  253.  
  254.         Private Sub div_Click(sender As Object, e As EventArgs)
  255.             If equop <> 1 Then
  256.                 prodcode()
  257.                 If opd = 0 Then
  258.                     c = Double.Parse(ansbox.Text)
  259.                 Else
  260.                     c = c / Double.Parse(ansbox.Text)
  261.                 End If
  262.  
  263.  
  264.                 op += 1
  265.             End If
  266.             opeq = 2
  267.             opd = 1
  268.         End Sub
  269.  
  270.  
  271.  
  272.         Private Sub min_Click(sender As Object, e As EventArgs)
  273.             If equop <> 1 Then
  274.                 prodcode()
  275.                 divcode()
  276.  
  277.                 If opm = 0 Then
  278.                     a += Double.Parse(ansbox.Text)
  279.                 Else
  280.  
  281.                     a -= Double.Parse(ansbox.Text)
  282.                     opm = 0
  283.                 End If
  284.  
  285.                 ansbox.Text = a.ToString()
  286.  
  287.  
  288.  
  289.                 op += 1
  290.             End If
  291.             equop = 0
  292.             opeq = 4
  293.             opm += 1
  294.         End Sub
  295.  
  296.  
  297.  
  298.         Private Sub sqrt_Click(sender As Object, e As EventArgs)
  299.             ansbox.Text = Math.Sqrt(Double.Parse(ansbox.Text)).ToString()
  300.         End Sub
  301.  
  302.         Private Sub overx_Click(sender As Object, e As EventArgs)
  303.             Dim temp As Double
  304.             temp = Double.Parse(ansbox.Text)
  305.             temp = 1 / temp
  306.             ansbox.Text = temp.ToString()
  307.  
  308.         End Sub
  309.  
  310.         Private Sub pom_Click(sender As Object, e As EventArgs)
  311.             ansbox.Text = "-" + ansbox.Text
  312.         End Sub
  313.  
  314.         Private Sub equals_Click(sender As Object, e As EventArgs)
  315.             Select Case opeq
  316.                 Case 1
  317.                     If a <> 0 Then
  318.                         a = a * Double.Parse(ansbox.Text)
  319.                         ansbox.Text = a.ToString()
  320.                     Else
  321.                         b = b * Double.Parse(ansbox.Text)
  322.                         ansbox.Text = b.ToString()
  323.                         a = b
  324.                     End If
  325.  
  326.                     Exit Select
  327.                 Case 2
  328.                     If a <> 0 Then
  329.                         a = a / Double.Parse(ansbox.Text)
  330.                         ansbox.Text = a.ToString()
  331.                     Else
  332.                         c = c / Double.Parse(ansbox.Text)
  333.                         ansbox.Text = c.ToString()
  334.                         a = c
  335.                     End If
  336.  
  337.                     Exit Select
  338.                 Case 3
  339.                     a = a + Double.Parse(ansbox.Text)
  340.                     ansbox.Text = a.ToString()
  341.                     Exit Select
  342.                 Case 4
  343.                     a = a - Double.Parse(ansbox.Text)
  344.                     ansbox.Text = a.ToString()
  345.                     Exit Select
  346.             End Select
  347.             op += 1
  348.             equop = 1
  349.  
  350.         End Sub
  351.  
  352.         Private Sub prodcode()
  353.             If opx <> 0 Then
  354.                 b = b * Double.Parse(ansbox.Text)
  355.                 ansbox.Text = b.ToString()
  356.                 b = 0
  357.                 opx = 0
  358.             End If
  359.  
  360.         End Sub
  361.         Private Sub divcode()
  362.             If opd <> 0 Then
  363.                 c = c / Double.Parse(ansbox.Text)
  364.                 ansbox.Text = c.ToString()
  365.                 c = 0
  366.                 opd = 0
  367.             End If
  368.         End Sub
  369.         Private Sub mincode()
  370.             If opm <> 0 Then
  371.                 a -= Double.Parse(ansbox.Text)
  372.                 opm = 0
  373.             End If
  374.         End Sub
  375.     End Class
  376. End Namespace
Add Comment
Please, Sign In to add comment