Home »
VB.Net »
VB.Net Programs
VB.Net program to create a Student class and read and print Student detail
By Nidhi Last Updated : November 11, 2024
Read and print student's details using class in VB.Net
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 code to read and print student's details using class
'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
S.ReadInfo()
S.PrintInfo()
End Sub
End Module
Output:
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 . . .
Explanation:
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 »