Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim primeiroNumero As Decimal
- Dim operacao As String
- Private Sub Num0_Click(sender As Object, e As EventArgs) Handles Num0.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "0"
- Else
- TextBox1.Text = TextBox1.Text & "0"
- End If
- End Sub
- Private Sub Num2_Click(sender As Object, e As EventArgs) Handles Num2.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "2"
- Else
- TextBox1.Text = TextBox1.Text & "2"
- End If
- End Sub
- Private Sub Num1_Click(sender As Object, e As EventArgs) Handles Num1.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "1"
- Else
- TextBox1.Text = TextBox1.Text & "1"
- End If
- End Sub
- Private Sub Num3_Click(sender As Object, e As EventArgs) Handles Num3.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "3"
- Else
- TextBox1.Text = TextBox1.Text & "3"
- End If
- End Sub
- Private Sub Num4_Click(sender As Object, e As EventArgs) Handles Num4.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "4"
- Else
- TextBox1.Text = TextBox1.Text & "4"
- End If
- End Sub
- Private Sub Num5_Click(sender As Object, e As EventArgs) Handles Num5.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "5"
- Else
- TextBox1.Text = TextBox1.Text & "5"
- End If
- End Sub
- Private Sub Num6_Click(sender As Object, e As EventArgs) Handles Num6.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "6"
- Else
- TextBox1.Text = TextBox1.Text & "6"
- End If
- End Sub
- Private Sub Num7_Click(sender As Object, e As EventArgs) Handles Num7.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "7"
- Else
- TextBox1.Text = TextBox1.Text & "7"
- End If
- End Sub
- Private Sub Num8_Click(sender As Object, e As EventArgs) Handles Num8.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "8"
- Else
- TextBox1.Text = TextBox1.Text & "8"
- End If
- End Sub
- Private Sub Num9_Click(sender As Object, e As EventArgs) Handles Num9.Click
- If TextBox1.Text = "0" Then
- TextBox1.Text = "9"
- Else
- TextBox1.Text = TextBox1.Text & "9"
- End If
- End Sub
- Private Sub Virgula_Click(sender As Object, e As EventArgs) Handles Virgula.Click
- TextBox1.Text = TextBox1.Text & ","
- End Sub
- Private Sub Soma_Click(sender As Object, e As EventArgs) Handles Soma.Click
- primeiroNumero = TextBox1.Text
- operacao = "+"
- Label1.Text = TextBox1.Text & " " & operacao
- TextBox1.Text = ""
- End Sub
- Private Sub Menos_Click(sender As Object, e As EventArgs) Handles Menos.Click
- primeiroNumero = TextBox1.Text
- operacao = "-"
- Label1.Text = TextBox1.Text & " " & operacao
- TextBox1.Text = ""
- End Sub
- Private Sub Multiplicar_Click(sender As Object, e As EventArgs) Handles Multiplicar.Click
- primeiroNumero = TextBox1.Text
- operacao = "*"
- Label1.Text = TextBox1.Text & " " & operacao
- TextBox1.Text = ""
- End Sub
- Private Sub Dividir_Click(sender As Object, e As EventArgs) Handles Dividir.Click
- primeiroNumero = TextBox1.Text
- operacao = "/"
- Label1.Text = TextBox1.Text & " " & operacao
- TextBox1.Text = ""
- End Sub
- Private Sub Igual_Click(sender As Object, e As EventArgs) Handles Igual.Click
- Dim segundoNumero, resultado As Decimal
- segundoNumero = TextBox1.Text
- If operacao = "+" Then
- resultado = primeiroNumero + segundoNumero
- ElseIf operacao = "-" Then
- resultado = primeiroNumero - segundoNumero
- ElseIf operacao = "*" Then
- resultado = primeiroNumero * segundoNumero
- ElseIf operacao = "/" Then
- resultado = primeiroNumero / segundoNumero
- End If
- TextBox1.Text = resultado
- Label1.Text = ""
- End Sub
- Private Sub OpC_Click(sender As Object, e As EventArgs) Handles OpC.Click
- If TextBox1.Text.Length > 0 Then
- TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length - 1)
- End If
- End Sub
- Private Sub OpCE_Click(sender As Object, e As EventArgs) Handles OpCE.Click
- TextBox1.Clear()
- Label1.Text = ""
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement