Ejemplo public sub vb.net

Aquí les muestro un ejemplo en visual basic usando el public sub la cual se utiliza para determinar una función en este ejemplo el public sub se usara para determinar dependiendo del simbolo que accion aser .

aqu el diseño:


Aquí el código:

Public Class Form1
    '' ejemplo declarando clases
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.Add("+")
        ComboBox1.Items.Add("-")
        ComboBox1.Items.Add("*")
        ComboBox1.Items.Add("/")

    End Sub
    Public Sub suma()
        TextBox3.Text = CInt(TextBox1.Text) + CInt(TextBox2.Text)
    End Sub
    Public Sub resta()
        TextBox3.Text = CInt(TextBox1.Text) - CInt(TextBox2.Text)
    End Sub
    Public Sub multiplicacion()
        TextBox3.Text = CInt(TextBox1.Text) * CInt(TextBox2.Text)
    End Sub
    Public Sub diviison()
        TextBox3.Text = CInt(TextBox1.Text) / CInt(TextBox2.Text)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.Text = "+" Then
            suma()
        ElseIf ComboBox1.Text = "-" Then
            resta()
        ElseIf ComboBox1.Text = "*" Then
            multiplicacion()
        ElseIf ComboBox1.Text = "/" Then
            diviison()
        End If


    End Sub
End Class




Descargar código:


                                                     vb.net

Comentarios

Populares

Buscar en este blog