VB.Net program to create a Student class and read and print Student detail

Here, we are going to learn how to create a Student class and read and print Student detail in VB.Net?
Submitted by Nidhi, on December 23, 2020

Here, we will create a Student class then read and print student information on the console screen.

Program/Source Code:

The source code to create a Student class and read and print Student detail is given below. The given program is compiled and executed successfully.

'VB.Net program to create a Student class and 
'read and print Student detail.

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

    Sub ReadInfo()
        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()
    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

    End Sub
End Module


Enter roll number: 101
Enter student name: Duggu Pandit
Enter student fees: 17999
Enter student address: New Delhi
Student Information
        Roll Number: 101
        Roll Name  : Duggu Pandit
        Fees       : 17999
        address    : New Delhi
Press any key to continue . . .


In the above program, we created a module Module1 that contains the Main() function. Here, we created a class Student class that contains 4 data members roll_no, name, fees, address. In the Student class we created two methods ReadInfo() and PrintInfo().

The ReadInfo() method is used to read the student information from the user. The PrintInfo() method is used to print the student detail on the console screen.

The Main() method is the entry point for the program, here we created the object of Student class then called ReadInfo() and PrintInfo() using an object to read and print student information.

VB.Net Basic Programs »



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.