Visual Studio

Home

Dicas

Exemplos Diversos

Class

Collection

Serialize/Deserialize

Forms

Exemplos

Comparação entre Dictionary , Collections e ArrayList

Criar Classe | Form para testar a classe | Form formatada | Código


Criar a Classe pessoa

 

 

Criar Form para testar a classe

 

Crie uma Form mais profissional para utilizar a classe Pessoa

 

Código Classe

Public Class Pessoa

 

    Private _codigo As String = ""

    Private _nome As String = ""

    Private _dataNasc As Date = Nothing

 

    Public Sub New()

 

    End Sub

 

    Public Sub New(ByVal codigo As String)

        _codigo = codigo

    End Sub

 

    Public Sub New(ByVal codigo As String, ByVal nome As String)

        _codigo = codigo

        _nome = nome

    End Sub

 

    Public Sub New(ByVal codigo As String, ByVal nome As String, ByVal dataNasc As Date)

        _codigo = codigo

        _nome = nome

        _dataNasc = dataNasc

    End Sub

 

    Public Property Codigo() As String

        Get

            Return _codigo

        End Get

        Set(ByVal value As String)

            _codigo = value

        End Set

    End Property

 

    Public Property Nome() As String

        Get

            Return _nome

        End Get

        Set(ByVal value As String)

            _nome = value

        End Set

    End Property

 

    Public Property DataNascimento() As Date

        Get

            Return _dataNasc

        End Get

        Set(ByVal value As Date)

            _dataNasc = value

        End Set

    End Property

 

    Public ReadOnly Property Idade() As Integer

        Get

            Return DateDiff(DateInterval.Year, _dataNasc, Today)

        End Get

 

    End Property

 

End Class