Advertisement
Guest User

Untitled

a guest
Apr 26th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.62 KB | None | 0 0
  1. Public Class Form4
  2.  
  3. Dim OP As String
  4.  
  5. Dim a, b, resultado, resp, pi As Double
  6.  
  7.  
  8. Private Sub Bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt1.Click
  9.  
  10. TxtCalc.Text = TxtCalc.Text + "1"
  11.  
  12. End Sub
  13.  
  14. Private Sub Bt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt2.Click
  15.  
  16. TxtCalc.Text = TxtCalc.Text + "2"
  17.  
  18. End Sub
  19.  
  20. Private Sub Bt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt3.Click
  21.  
  22. TxtCalc.Text = TxtCalc.Text + "3"
  23.  
  24. End Sub
  25.  
  26. Private Sub Bt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt4.Click
  27.  
  28. TxtCalc.Text = TxtCalc.Text + "4"
  29.  
  30. End Sub
  31.  
  32. Private Sub Bt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt5.Click
  33.  
  34. TxtCalc.Text = TxtCalc.Text + "5"
  35.  
  36. End Sub
  37.  
  38. Private Sub Bt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt6.Click
  39.  
  40. TxtCalc.Text = TxtCalc.Text + "6"
  41.  
  42. End Sub
  43.  
  44. Private Sub Bt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt7.Click
  45.  
  46. TxtCalc.Text = TxtCalc.Text + "7"
  47.  
  48. End Sub
  49.  
  50. Private Sub Bt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt8.Click
  51.  
  52. TxtCalc.Text = TxtCalc.Text + "8"
  53.  
  54. End Sub
  55.  
  56. Private Sub Bt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt9.Click
  57.  
  58. TxtCalc.Text = TxtCalc.Text + "9"
  59.  
  60. End Sub
  61.  
  62. Private Sub Bt0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt0.Click
  63.  
  64. TxtCalc.Text = TxtCalc.Text + "0"
  65.  
  66. End Sub
  67.  
  68. Private Sub BtPonto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtPonto.Click
  69.  
  70. TxtCalc.Text = TxtCalc.Text + ","
  71.  
  72. End Sub
  73.  
  74. Private Sub BtC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtC.Click
  75.  
  76. TxtCalc.Text = ""
  77.  
  78. End Sub
  79.  
  80. Private Sub Btsoma_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btsoma.Click
  81.  
  82. a = TxtCalc.Text
  83. TxtCalc.Text = " "
  84. OP = "Suma"
  85.  
  86. End Sub
  87.  
  88. Private Sub Btmenos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btmenos.Click
  89. a = TxtCalc.Text
  90. TxtCalc.Text = " "
  91. OP = "Menos"
  92. End Sub
  93.  
  94. Private Sub Btdividir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btdividir.Click
  95. a = TxtCalc.Text
  96. TxtCalc.Text = " "
  97. OP = "Div"
  98. End Sub
  99.  
  100. Private Sub Btmulti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btmulti.Click
  101. a = TxtCalc.Text
  102. TxtCalc.Text = " "
  103. OP = "Multi"
  104. End Sub
  105.  
  106. Private Sub Btigual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btigual.Click
  107.  
  108. b = Val(TxtCalc.Text)
  109.  
  110. Select Case OP
  111.  
  112. Case "Suma"
  113. resultado = a + b
  114. TxtCalc.Text = resultado
  115.  
  116. Case "Menos"
  117. resultado = a - b
  118. TxtCalc.Text = resultado
  119.  
  120. Case "Multi"
  121. resultado = a * b
  122. TxtCalc.Text = resultado
  123.  
  124. Case "Div"
  125. resultado = a / b
  126. TxtCalc.Text = resultado
  127.  
  128. Case "Elevado"
  129. resultado = Math.Pow(a, b)
  130. TxtCalc.Text = resultado
  131.  
  132. Case "Porcento"
  133. resp = b / 100
  134. resultado = resp * a
  135. TxtCalc.Text = resultado
  136.  
  137. End Select
  138.  
  139. End Sub
  140.  
  141. Private Sub LimparToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LimparToolStripMenuItem.Click
  142.  
  143. TxtCalc.Text = ""
  144.  
  145. End Sub
  146.  
  147. Private Sub CorDeFundoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CorDeFundoToolStripMenuItem.Click
  148.  
  149. Dim cores As New ColorDialog()
  150.  
  151. If cores.ShowDialog() = Windows.Forms.DialogResult.OK Then
  152. Me.BackColor = cores.Color
  153. End If
  154.  
  155. End Sub
  156.  
  157. Private Sub FecharToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FecharToolStripMenuItem.Click
  158. Me.Close()
  159. End Sub
  160.  
  161. Private Sub Btraiz_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btraiz.Click
  162.  
  163. a = TxtCalc.Text
  164. TxtCalc.Text = Math.Sqrt(a)
  165.  
  166. End Sub
  167.  
  168. Private Sub Btcos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btcos.Click
  169.  
  170. a = TxtCalc.Text
  171. TxtCalc.Text = Math.Cos(a)
  172.  
  173. End Sub
  174.  
  175. Private Sub Btsen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btsen.Click
  176.  
  177. a = TxtCalc.Text
  178. TxtCalc.Text = Math.Sin(a)
  179.  
  180. End Sub
  181.  
  182. Private Sub Bttan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bttan.Click
  183.  
  184. a = TxtCalc.Text
  185. TxtCalc.Text = Math.Tan(a)
  186.  
  187. End Sub
  188.  
  189. Private Sub Btlog10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btlog10.Click
  190. a = TxtCalc.Text
  191. TxtCalc.Text = Math.Log10(d:=Val(a))
  192. End Sub
  193.  
  194. Private Sub Btln_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btln.Click
  195. a = TxtCalc.Text
  196. TxtCalc.Text = Math.Log(d:=Val(a))
  197. End Sub
  198.  
  199. Private Sub Btx2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btx2.Click
  200.  
  201. a = TxtCalc.Text
  202. TxtCalc.Text = a * a
  203.  
  204. End Sub
  205.  
  206. Private Sub Btx3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btx3.Click
  207.  
  208. a = TxtCalc.Text
  209. TxtCalc.Text = a * a * a
  210.  
  211. End Sub
  212.  
  213. Private Sub Btxy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btxy.Click
  214.  
  215. a = TxtCalc.Text
  216. TxtCalc.Text = ""
  217. OP = "Elevado"
  218.  
  219. End Sub
  220.  
  221. Private Sub BtMM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtMM.Click
  222. TxtCalc.Text = -+TxtCalc.Text
  223. End Sub
  224.  
  225. Private Sub Btpi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btpi.Click
  226. 'valor de pi
  227. pi = "3,14159265358979323846264338327950288"
  228. a = pi
  229.  
  230. End Sub
  231.  
  232. Private Sub Btcento_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btcento.Click
  233.  
  234.  
  235. OP = "Porcento"
  236.  
  237. End Sub
  238. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement