ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the simple inheritance with student information

Here, we are going to demonstrate the simple inheritance with student information in VB.Net.
Submitted by Nidhi, on December 26, 2020

Here, we will demonstrate the simple inheritance with student information by creating PersonalInfo and StudentResultInfo class.

Program/Source Code:

The source code to demonstrate the simple inheritance with student information is given below. The given program is compiled and executed successfully.

'VB.net program to demonstrate the simple inheritance 
'with student information.

Module Module1
    Class PersonalInfo
        Dim id As Integer
        Dim name As String

        Public Sub SetPersonalInfo(ByVal i As Integer, ByVal n As String)
            id = i
            name = n
        End Sub

        Public Sub PrintPersonalInfo()
            Console.WriteLine("Id      : {0}", id)
            Console.WriteLine("Name    : {0}", name)
        End Sub
    End Class

    Class StudentResultInfo
        Inherits PersonalInfo
        Dim marks As Integer
        Dim per As Double
        Dim grade As String

        Public Sub SetInfo(ByVal i As Integer, ByVal n As String, ByVal m As Integer, ByVal p As Double, ByVal g As String)
            SetPersonalInfo(i, n)
            marks = m
            per = p
            grade = g
        End Sub
        Public Sub PrintInfo()
            PrintPersonalInfo()
            Console.WriteLine("Marks   : {0}", marks)
            Console.WriteLine("Per     : {0}", per)
            Console.WriteLine("Grade   : {0}", grade)
        End Sub
    End Class
    
    Sub Main()
        Dim S As New StudentResultInfo()

        S.SetInfo(101, "Rohit", 452, 90.4, "A")
        S.PrintInfo()
    End Sub
    
End Module

Output:

Id      : 101
Name    : Rohit
Marks   : 452
Per     : 90.4
Grade   : A
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1. Here, we created two classes PersonalInfo and StudentResultInfo class to implement simple inheritance.

The PersonalInfo contains two methods SetPersonalInfo() and PrintPersonalInfo() to set and print the personal information of a student. The StudentResultInfo also contains two methods SetInfo() and PrintInfo() to set and print academic information of a student.

At last, we created a Main() function, which is the entry point for the program, here we created the object of StudentResultInfo class and set and print student information on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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

© https://www.includehelp.com some rights reserved.