VB.Net Program to Demonstrate the Private Methods Inside the Class

You are currently viewing VB.Net Program to Demonstrate the Private Methods Inside the Class

VB.Net program to demonstrate the private methods inside the class

'VB.Net program to demonstrate the private methods inside the class.

Class Student
    Private roll_no As Integer
    Private name As String
    Private fees As Integer
    Private address As String

    Private Sub ReadStart()
        Console.WriteLine("Start reading from user")
    End Sub

    Private Sub ReadStop()
        Console.WriteLine("Stop reading")
    End Sub

    Sub ReadInfo()
        ReadStart()
        Console.Write("Enter roll number: ")
        roll_no = Integer.Parse(Console.ReadLine())

        Console.Write("Enter student name: ")
        name = Console.ReadLine()

        Console.Write("Enter student fees: ")
        fees = Integer.Parse(Console.ReadLine())

        Console.Write("Enter student address: ")
        address = Console.ReadLine()
        ReadStop()
    End Sub

    Sub PrintInfo()
        Console.WriteLine("Student Information")
        Console.WriteLine(vbTab & "Roll Number: " & roll_no)
        Console.WriteLine(vbTab & "Roll Name  : " & name)
        Console.WriteLine(vbTab & "Fees       : " & fees)
        Console.WriteLine(vbTab & "address    : " & address)
    End Sub
End Class

Module Module1
    Sub Main()
        Dim S As New Student

        S.ReadInfo()
        S.PrintInfo()
    End Sub
End Module

Output

Start reading from user
Enter roll number: 101
Enter student name: Alex carry
Enter student fees: 23457
Enter student address: USA
Stop reading
Student Information
        Roll Number: 101
        Roll Name  : Alex carry
        Fees       : 23457
        address    : USA
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply