Public and private demo : Private « Class « VB.Net

Public and private demo

Public and private demo
Imports System.IO

Module Module1

    Sub Main()
        Dim p As New Professor()

        p.Name = "JOe"
        p.OfficeNumber = "123A"


    End Sub

End Module

    Class Professor
        Public Name As String
        Private Age As Integer
        Public OfficeNumber As String
        Private HomePhone As String

        Public Sub ShowProfessor()
            Console.WriteLine("Name: " & Name)
            Console.WriteLine("Age: " & Age)
            Console.WriteLine("Office Number: " & OfficeNumber)
            Console.WriteLine("Home Phone: " & HomePhone)
        End Sub

        Public Sub AssignAge(ByVal EmpAge As Integer)
            If (EmpAge > 18) And (EmpAge < 100) Then
                Age = EmpAge
            End If
        End Sub

        Public Sub AssignHomePhone(ByVal Phone As String)
            HomePhone = Phone
        End Sub
    End Class


Related examples in the same category

1.Private Member Variable