Guest User

Untitled

a guest
Apr 26th, 2014
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // variaveis do form
  2.  
  3.  
  4. Dim OP As String
  5.  
  6. Dim a, b, resultado, resp, pi As Double
  7.  
  8.  
  9. // botao soma, menos, dividir, multiplicacao
  10.  
  11. Private Sub Btsoma_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btsoma.Click
  12.  
  13. a = TxtCalc.Text
  14. TxtCalc.Text = " "
  15. OP = "Suma"
  16.  
  17. End Sub
  18.  
  19. Private Sub Btmenos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btmenos.Click
  20. a = TxtCalc.Text
  21. TxtCalc.Text = " "
  22. OP = "Menos"
  23. End Sub
  24.  
  25. Private Sub Btdividir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btdividir.Click
  26. a = TxtCalc.Text
  27. TxtCalc.Text = " "
  28. OP = "Div"
  29. End Sub
  30.  
  31. Private Sub Btmulti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btmulti.Click
  32. a = TxtCalc.Text
  33. TxtCalc.Text = " "
  34. OP = "Multi"
  35. End Sub
  36.  
  37.  
  38. // botão do igual
  39.  
  40. Private Sub Btigual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btigual.Click
  41.  
  42. b = Val(TxtCalc.Text)
  43.  
  44. Select Case OP
  45.  
  46. Case "Suma"
  47. resultado = a + b
  48. TxtCalc.Text = resultado
  49.  
  50. Case "Menos"
  51. resultado = a - b
  52. TxtCalc.Text = resultado
  53.  
  54. Case "Multi"
  55. resultado = a * b
  56. TxtCalc.Text = resultado
  57.  
  58. Case "Div"
  59. resultado = a / b
  60. TxtCalc.Text = resultado
  61.  
  62. Case "Elevado"
  63. resultado = Math.Pow(a, b)
  64. TxtCalc.Text = resultado
  65.  
  66. Case "Porcento"
  67. resp = b / 100
  68. resultado = resp * a
  69. TxtCalc.Text = resultado
  70.  
  71. End Select
  72.  
  73. End Sub
RAW Paste Data