Advertisement
ManuMaloka

Mini Projeto 16

Apr 27th, 2023
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.     Dim primeiroNumero As Decimal
  3.     Dim operacao As String
  4.  
  5.  
  6.     Private Sub Num0_Click(sender As Object, e As EventArgs) Handles Num0.Click
  7.         If TextBox1.Text = "0" Then
  8.             TextBox1.Text = "0"
  9.         Else
  10.             TextBox1.Text = TextBox1.Text & "0"
  11.         End If
  12.  
  13.     End Sub
  14.  
  15.     Private Sub Num2_Click(sender As Object, e As EventArgs) Handles Num2.Click
  16.         If TextBox1.Text = "0" Then
  17.             TextBox1.Text = "2"
  18.         Else
  19.             TextBox1.Text = TextBox1.Text & "2"
  20.         End If
  21.  
  22.     End Sub
  23.  
  24.     Private Sub Num1_Click(sender As Object, e As EventArgs) Handles Num1.Click
  25.         If TextBox1.Text = "0" Then
  26.             TextBox1.Text = "1"
  27.         Else
  28.             TextBox1.Text = TextBox1.Text & "1"
  29.         End If
  30.  
  31.     End Sub
  32.  
  33.     Private Sub Num3_Click(sender As Object, e As EventArgs) Handles Num3.Click
  34.         If TextBox1.Text = "0" Then
  35.             TextBox1.Text = "3"
  36.         Else
  37.             TextBox1.Text = TextBox1.Text & "3"
  38.         End If
  39.  
  40.     End Sub
  41.  
  42.     Private Sub Num4_Click(sender As Object, e As EventArgs) Handles Num4.Click
  43.         If TextBox1.Text = "0" Then
  44.             TextBox1.Text = "4"
  45.         Else
  46.             TextBox1.Text = TextBox1.Text & "4"
  47.         End If
  48.  
  49.     End Sub
  50.  
  51.     Private Sub Num5_Click(sender As Object, e As EventArgs) Handles Num5.Click
  52.         If TextBox1.Text = "0" Then
  53.             TextBox1.Text = "5"
  54.         Else
  55.             TextBox1.Text = TextBox1.Text & "5"
  56.         End If
  57.  
  58.     End Sub
  59.  
  60.     Private Sub Num6_Click(sender As Object, e As EventArgs) Handles Num6.Click
  61.         If TextBox1.Text = "0" Then
  62.             TextBox1.Text = "6"
  63.         Else
  64.             TextBox1.Text = TextBox1.Text & "6"
  65.         End If
  66.  
  67.     End Sub
  68.  
  69.     Private Sub Num7_Click(sender As Object, e As EventArgs) Handles Num7.Click
  70.         If TextBox1.Text = "0" Then
  71.             TextBox1.Text = "7"
  72.         Else
  73.             TextBox1.Text = TextBox1.Text & "7"
  74.         End If
  75.  
  76.     End Sub
  77.  
  78.     Private Sub Num8_Click(sender As Object, e As EventArgs) Handles Num8.Click
  79.         If TextBox1.Text = "0" Then
  80.             TextBox1.Text = "8"
  81.         Else
  82.             TextBox1.Text = TextBox1.Text & "8"
  83.         End If
  84.  
  85.     End Sub
  86.  
  87.     Private Sub Num9_Click(sender As Object, e As EventArgs) Handles Num9.Click
  88.         If TextBox1.Text = "0" Then
  89.             TextBox1.Text = "9"
  90.         Else
  91.             TextBox1.Text = TextBox1.Text & "9"
  92.         End If
  93.  
  94.     End Sub
  95.  
  96.     Private Sub Virgula_Click(sender As Object, e As EventArgs) Handles Virgula.Click
  97.         TextBox1.Text = TextBox1.Text & ","
  98.     End Sub
  99.  
  100.     Private Sub Soma_Click(sender As Object, e As EventArgs) Handles Soma.Click
  101.         primeiroNumero = TextBox1.Text
  102.         operacao = "+"
  103.         Label1.Text = TextBox1.Text & " " & operacao
  104.         TextBox1.Text = ""
  105.     End Sub
  106.  
  107.     Private Sub Menos_Click(sender As Object, e As EventArgs) Handles Menos.Click
  108.         primeiroNumero = TextBox1.Text
  109.         operacao = "-"
  110.         Label1.Text = TextBox1.Text & " " & operacao
  111.         TextBox1.Text = ""
  112.     End Sub
  113.  
  114.     Private Sub Multiplicar_Click(sender As Object, e As EventArgs) Handles Multiplicar.Click
  115.         primeiroNumero = TextBox1.Text
  116.         operacao = "*"
  117.         Label1.Text = TextBox1.Text & " " & operacao
  118.         TextBox1.Text = ""
  119.     End Sub
  120.  
  121.     Private Sub Dividir_Click(sender As Object, e As EventArgs) Handles Dividir.Click
  122.         primeiroNumero = TextBox1.Text
  123.         operacao = "/"
  124.         Label1.Text = TextBox1.Text & " " & operacao
  125.         TextBox1.Text = ""
  126.     End Sub
  127.  
  128.     Private Sub Igual_Click(sender As Object, e As EventArgs) Handles Igual.Click
  129.         Dim segundoNumero, resultado As Decimal
  130.  
  131.         segundoNumero = TextBox1.Text
  132.  
  133.         If operacao = "+" Then
  134.             resultado = primeiroNumero + segundoNumero
  135.         ElseIf operacao = "-" Then
  136.             resultado = primeiroNumero - segundoNumero
  137.         ElseIf operacao = "*" Then
  138.             resultado = primeiroNumero * segundoNumero
  139.         ElseIf operacao = "/" Then
  140.             resultado = primeiroNumero / segundoNumero
  141.         End If
  142.  
  143.         TextBox1.Text = resultado
  144.         Label1.Text = ""
  145.  
  146.     End Sub
  147.  
  148.     Private Sub OpC_Click(sender As Object, e As EventArgs) Handles OpC.Click
  149.         If TextBox1.Text.Length > 0 Then
  150.             TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length - 1)
  151.         End If
  152.     End Sub
  153.  
  154.     Private Sub OpCE_Click(sender As Object, e As EventArgs) Handles OpCE.Click
  155.         TextBox1.Clear()
  156.         Label1.Text = ""
  157.     End Sub
  158.  
  159. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement