Clases y Formularios con Visual Basic.NET 2008

PROGRAMACIÓN ORIENTADA A OBJETOS (POO)
Creamos la siguiente clase denominada CLSPLANILLA (ClsPlanilla.vb)
Public Class ClsPlanilla
    Private nombres As String
    Private apellidos As String
    Private sueldo As Double
    Private aumento As Double
    Private descuento As Double
    Private sneto As Double
    Public Property pnombres() As String
        Get
            Return nombres
        End Get
        Set(ByVal value As String)
            nombres = value
        End Set
    End Property
    Public Property papellidos() As String
        Get
            Return apellidos
        End Get
        Set(ByVal value As String)
            apellidos = value
        End Set
    End Property
    Public Property psueldo() As Double
        Get
            Return sueldo
        End Get
        Set(ByVal value As Double)
            sueldo = value
        End Set
    End Property
    Public Property paumento() As Double
        Get
            Return aumento
        End Get
        Set(ByVal value As Double)
            aumento = value
        End Set
    End Property
    Public Property pdescuento() As Double
        Get
            Return descuento
        End Get
        Set(ByVal value As Double)
            descuento = value
        End Set
    End Property
    Public Property psneto() As Double
        Get
            Return sneto
        End Get
        Set(ByVal value As Double)
            sneto = value
        End Set
    End Property
End Class
Diseñamos el siguiente formulario:


Codificamos en el botón calcular (Instanciamos la clase CLSPLANILLA):
        Dim obje As New ClsPlanilla
        obje.pnombres = txtnom.Text
        obje.papellidos = txtape.Text
        obje.psueldo = txtsue.Text
        obje.paumento = Double.Parse(obje.psueldo) * 0.05
        obje.pdescuento = Double.Parse(obje.psueldo) * 0.09
        obje.psneto = Double.Parse(obje.psueldo) + Double.Parse(obje.paumento)
        MsgBox("Empleado: " & obje.pnombres & " " & obje.papellidos & Chr(13) & _
               "Sueldo: " & obje.psueldo & Chr(13) & _
               "Aumento 5%: " & obje.paumento & Chr(13) & _
               "Descuento 9%: " & obje.pdescuento & Chr(13) & _
               "Sueldo Neto: " & obje.psneto)

Guarde y ejecute la aplicación. Se mostrara el siguiente mensaje con las propiedades get y set de la clase CLSPLANILLA:


Espero te sirva...
Para mis seguidores de NICARAGUA
Prof. Jhonatan Abal Mejia

Comentarios

Entradas populares

Ejercicios Consola Visual Basic.NET

Numero Capicua Visual Basic

Procedimientos Almacenados ORACLE