Blog de Daiyiro

#BlogDeDaiyiro es sobre todo Bricolajes de Electrónica/Informática. ¡^-^¡

LO NUEVO:

14.10.13

Crear Calculadora Con Vb.Net

Este es otro ejercicio que hice en el curso, se trata de una calculadora, consta de 1formulario, con unos cuantos buttons y 1 text.box para mostrar lo pulsado y resultados de la calculadora.



de modo que se quedaría así:



y este seria el CÓDIGO DEL FORM 1:


Public Class Form1

    Dim m As Integer
    Dim s As Integer
    Dim r As Integer
    Dim x As Integer
    Dim d As Integer
    Dim op As Integer


    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Tb1.Text = Tb1.Text + Button11.Text
    End Sub

    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        m = Tb1.Text
        Tb1.Clear()
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Tb1.Text = Tb1.Text + Button10.Text
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

        If op = 1 Then
            Tb1.Text = Int(Tb1.Text) + s
        End If

        If op = 2 Then
            Tb1.Text = r - Int(Tb1.Text)

        End If

        If op = 3 Then
            Tb1.Text = Int(Tb1.Text) * x
        End If

        If op = 4 Then
            Tb1.Text = d / Int(Tb1.Text)
        End If
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        d = Tb1.Text
        op = 4
        Tb1.Clear()
    End Sub

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

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

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

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

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

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

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

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

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Tb1.Text = Tb1.Text + Button9.Text
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click

        s = Tb1.Text
        op = 1
        Tb1.Clear()

    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        r = Tb1.Text
        op = 2
        Tb1.Clear()
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        x = Tb1.Text
        op = 3
        Tb1.Clear()
    End Sub

    Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
        Tb1.Text = m
    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Tb1.Text = "0"
        Tb1.Clear()
    End Sub

End Class


Una Captura ejecutándose:



Descargar Calculadora.rar

Espero que os sea de interés..

Un Saludiioo.

1 comentario:

  1. Tambien me descargado este, gracias, funcionan los ejemplos, creo que me los voy a descargar todos, entre los cursos y los ejercicios estoy aprendiendo bastante :D

    ResponderEliminar