VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to implement Multiple Interface Inheritance in VB.NET

by Hari Reddy (5 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 12th October 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to implement Multiple Interface Inheritance in VB.NET

Rate How to implement Multiple Interface Inheritance in VB.NET




Option Explicit On 
Option Strict On

Imports Microsoft.VisualBasic 'import all functionalities of Visual Basic
Imports Microsoft.VisualBasic.Compatibility.VB6 'import vb6 compatibility

Module General
    
    Public Sub Main()
        
        Dim aEmployee As New Employee()
        Dim sMessage As String
        With aEmployee
            
            .EmpID = "1234"
            .EmpName = "Hari"
            .AccountNo = "AC01"
            .AccountName = "Hari Srinivas Reddy"
            .BankName = "HDFC"
            .BankAddress = "Pune"
            .BranchName = "Boat Club"
            .CompanyName = "ABC LTD"
            .CompanyAddress = "Pune"
            
            .Basic = 10500
            .Hra = 4400
            .Ca = 5000
            .Edu = 100
            .Pf = 1200
            
            sMessage = "Emp ID :" & .EmpID & vbCrLf & _
                       "Emp Name : " & .EmpName & vbCrLf & _
                       "Account No : " & .AccountNo & vbCrLf & _
                       "Account Name : " & .AccountName & vbCrLf & _
                       "Bank Name : " & .BankName & vbCrLf & _
                       "Bank Address : " & .BankAddress & vbCrLf & _
                       "Brank Name : " & .BranchName & vbCrLf & _
                       "Company Name: " & .CompanyName & vbCrLf & _
                       "Company Address: " & .CompanyAddress & vbCrLf & _
                       "Gross Salary : " & CStr(.GetGross) & vbCrLf & _
                       "Total Deductions : " & CStr(.GetDeductions) & vbCrLf & _
                       "Net Salary : " & CStr(.GetNetSalary)
            
            MsgBox(sMessage, MsgBoxStyle.Information, "Check Info")
            
        End With
        
        aEmployee = Nothing
        
    End Sub
    
End Module

'create new blank class as Accountinfo and paste the following code in it.

Option Explicit On 
Option Strict On

Interface AccountInfo 
    
    Property AccountNo() As String
    Property AccountName() As String
    Property BankName() As String
    Property BankAddress() As String
    Property BranchName() As String
    
End Interface

'create new blank class as Company and paste the following code in it.

Option Explicit On 
Option Strict On

Interface Company
    
    Property CompanyName() As String
    Property CompanyAddress() As String
    
End Interface


'create new blank class as Paystructure and paste the following code in it.

Option Explicit On 
Option Strict On

Interface PayStructure
    
    Property Basic() As Single
    Property Hra() As Single
    Property Edu() As Single
    Property Ca() As Single
    Property Pf() As Single
    
    Function GetGross() As Single
    Function GetNetSalary() As Single
    Function GetDeductions() As Single
    
End Interface


'create new blank Class as Employee and paste the following code in it.
'this class implements above three interfaces

Option Explicit On 
Option Strict On

Public Class Employee
    
    Implements AccountInfo, Company, PayStructure
    
    Private m_sAccountNo As String
    Private m_sAccountName As String
    Private m_sBankName As String
    Private m_sBankAddress As String
    Private m_sBranchName As String
    
    Private m_sCompanyName As String
    Private m_sCompanyAddress As String
    
    Private m_sngBasic As Single
    Private m_sngHra As Single
    Private m_sngEdu As Single
    Private m_sngCa As Single
    Private m_sngPf As Single
    
    Private m_sEmpID As String
    Private m_sEmpName As String
    Private m_sDepartment As String
    
    
    Public Property AccountNo() As String Implements AccountInfo.AccountNo
        
        Get
            Return m_sAccountNo
        End Get
        
        Set
            m_sAccountNo = Value
        End Set
        
        
    End Property
    
    Public Property AccountName() As String Implements AccountInfo.Accountname
        Get
            Return m_sAccountName
        End Get
        Set
            m_sAccountName = Value
        End Set
    End Property
    
    Public Property BankName() As String Implements AccountInfo.BankName
        Get
            Return m_sBankName
        End Get
        Set
            m_sBankName = Value
        End Set
    End Property
    
    Public Property BankAddress() As String Implements AccountInfo.BankAddress
        Get
            Return m_sBankAddress
        End Get
        Set
            m_sBankAddress = Value
        End Set
    End Property
    
    Public Property BranchName() As String Implements AccountInfo.BranchName
        Get
            Return m_sBranchName
        End Get
        Set
            m_sBranchName = Value
        End Set
    End Property
    
    Public Property CompanyName() As String Implements Company.CompanyName
        Get
            Return m_sCompanyName
        End Get
        Set
            m_sCompanyName = Value
        End Set
    End Property
    
    Public Property CompanyAddress() As String Implements Company.CompanyAddress
        Get
            Return m_sCompanyAddress
        End Get
        Set
            m_sCompanyAddress = Value
        End Set
    End Property
    
    Public Property Basic() As Single Implements PayStructure.Basic
        Get
            Return m_sngBasic
        End Get
        Set
            m_sngBasic = Value
        End Set
    End Property
    
    Public Property Hra() As Single Implements PayStructure.Hra
        Get
            Return m_sngHra
        End Get
        Set
            m_sngHra = Value
        End Set
    End Property
    
    Public Property Ca() As Single Implements PayStructure.Ca
        Get
            Return m_sngCa
        End Get
        Set
            m_sngCa = Value
        End Set
    End Property
    
    Public Property Edu() As Single Implements PayStructure.edu
        Get
            Return m_sngEdu
        End Get
        Set
            m_sngEdu = Value
        End Set
    End Property
    
    Public Property Pf() As Single Implements PayStructure.pf
        Get
            Return m_sngPf
        End Get
        Set
            m_sngPf = Value
        End Set
    End Property
    
    Public Function GetGross() As Single Implements PayStructure.GetGross
        
        GetGross = m_sngBasic + m_sngHra + m_sngCa + m_sngEdu
        
    End Function
    
    Public Function GetNetSalary() As Single Implements PayStructure.GetNetSalary
        
        GetNetSalary = m_sngBasic + m_sngHra + m_sngCa + m_sngEdu - m_sngPf
        
    End Function
    
    Public Function GetDeductions() As Single Implements PayStructure.GetDeductions
        
        GetDeductions = m_sngPf
        
    End Function
    
    Public Property EmpID() As String
        
        Get
            Return m_sEmpID
        End Get
        
        Set
            m_sEmpID = Value
            
        End Set
        
    End Property
    
    Public Property EmpName() As String
        
        Get
            Return m_sEmpName
        End Get
        
        Set
            m_sEmpname = Value
            
        End Set
        
    End Property
    
    Public Property Department() As String
        
        Get
            Return m_sDepartment
        End Get
        
        Set
            m_sDepartment = Value
            
        End Set
        
    End Property
    
    
End Class


Download this snippet    Add to My Saved Code

How to implement Multiple Interface Inheritance in VB.NET Comments

No comments have been posted about How to implement Multiple Interface Inheritance in VB.NET. Why not be the first to post a comment about How to implement Multiple Interface Inheritance in VB.NET.

Post your comment

Subject:
Message:
0/1000 characters