miércoles, 7 de junio de 2017

CÓDIGO DE LA CALCULADORA






Public Class Form1
    Dim DATO As Double
    Dim DATO2 As Double
    Dim RESUL As Double
    Dim OPE As Double

    Private Sub Buttonsuma_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsuma.Click
        OPE = 1
        DATO = Val(TextBox1.Text)
        TextBox1.Clear()
    End Sub

    Private Sub Buttonresta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonresta.Click
        OPE = 2
        DATO = Val(TextBox1.Text)
        TextBox1.Clear()

    End Sub

    Private Sub Buttonmultiplicacion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonmultiplicacion.Click
        OPE = 3
        DATO = Val(TextBox1.Text)
        TextBox1.Clear()
    End Sub

    Private Sub Buttondivision_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttondivision.Click
        OPE = 4
        DATO = Val(TextBox1.Text)
        TextBox1.Clear()
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        DATO2 = Val(TextBox1.Text)
        If OPE = 1 Then
            RESUL = DATO + DATO2
            TextBox1.Text = RESUL
        Else
            If OPE = 2 Then
                RESUL = DATO - DATO2
                TextBox1.Text = RESUL
            Else
                If OPE = 3 Then
                    RESUL = DATO * DATO2
                    TextBox1.Text = RESUL
                Else
                    If OPE = 4 Then
                        RESUL = DATO / DATO2
                        TextBox1.Text = RESUL
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = TextBox1.Text & 1
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = TextBox1.Text & 2
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = TextBox1.Text & 3
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox1.Text = TextBox1.Text & 4
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Text = TextBox1.Text & 5
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox1.Text = TextBox1.Text & 6
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox1.Text = TextBox1.Text & 7
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox1.Text = TextBox1.Text & 8
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox1.Text = TextBox1.Text & 9
    End Sub
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        TextBox1.Text = TextBox1.Text & 0
    End Sub
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        TextBox1.Text = ""
    End Sub
End Class

0 comentarios:

Publicar un comentario