MatheusSMartins

Calculadora

Mar 1st, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.68 KB | None | 0 0
  1. Public Class Form1
  2.     Dim valor As Double
  3.     Dim valor2 As Double
  4.     Dim OP As Double
  5.  
  6.     Dim resultado As Double
  7.     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  8.  
  9.     End Sub
  10.  
  11.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  12.  
  13.     End Sub
  14.  
  15.     Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
  16.         TextBox1.Text += ("0")
  17.     End Sub
  18.  
  19.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  20.         TextBox1.Text += ("2")
  21.     End Sub
  22.  
  23.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  24.         TextBox1.Text += ("3")
  25.     End Sub
  26.  
  27.     Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  28.         TextBox1.Text += ("1")
  29.     End Sub
  30.  
  31.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  32.         TextBox1.Text += ("4")
  33.     End Sub
  34.  
  35.     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  36.         TextBox1.Text += ("5")
  37.     End Sub
  38.  
  39.     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  40.         TextBox1.Text += ("6")
  41.     End Sub
  42.  
  43.     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  44.         TextBox1.Text += ("7")
  45.     End Sub
  46.  
  47.     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  48.         TextBox1.Text += ("8")
  49.     End Sub
  50.  
  51.     Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  52.         TextBox1.Text += ("9")
  53.     End Sub
  54.  
  55.     Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
  56.         TextBox1.Text += ("+")
  57.         valor = Val(TextBox1.Text)
  58.         TextBox1.Clear()
  59.         OP = 1
  60.     End Sub
  61.  
  62.     Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
  63.         TextBox1.Text += ("/")
  64.         valor = Val(TextBox1.Text)
  65.         TextBox1.Clear()
  66.         OP = 2
  67.     End Sub
  68.  
  69.     Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
  70.         TextBox1.Text += ("*")
  71.         valor = Val(TextBox1.Text)
  72.         TextBox1.Clear()
  73.         OP = 3
  74.     End Sub
  75.  
  76.     Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
  77.         TextBox1.Text += ("-")
  78.         valor = Val(TextBox1.Text)
  79.         TextBox1.Clear()
  80.         OP = 4
  81.     End Sub
  82.  
  83.     Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
  84.         valor2 = Val(TextBox1.Text)
  85.         If OP = 4 Then
  86.             resultado = valor - valor2
  87.             TextBox1.Text = (resultado)
  88.         End If
  89.         If OP = 3 Then
  90.             resultado = valor * valor2
  91.             TextBox1.Text = (resultado)
  92.         End If
  93.         If OP = 1 Then
  94.             resultado = valor + valor2
  95.             TextBox1.Text = (resultado)
  96.         End If
  97.         If OP = 2 Then
  98.             resultado = valor / valor2
  99.             TextBox1.Text = (resultado)
  100.         End If
  101.  
  102.     End Sub
  103.  
  104.     Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
  105.         TextBox1.Clear()
  106.     End Sub
  107. End Class
Advertisement
Add Comment
Please, Sign In to add comment