Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Inheritance with VB.NET 2005
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Inheritance with VB.NET 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 35
    2006-07-18

    Table of Contents:
  • Inheritance with VB.NET 2005
  • Basic inheritance
  • Adding your own members to the sub class during inheritance
  • Multi-level inheritance in Visual Basic 2005
  • Dealing with constructors during inheritance
  • Dealing with constructors with parameters during inheritance

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Inheritance with VB.NET 2005 - Multi-level inheritance in Visual Basic 2005


    (Page 4 of 6 )

    Until now, in all of the previous sections, I introduced you only to single inheritance.  Now, I shall introduce you to multi-level inheritance. 

    When you define more than two levels of inheritance (in the form of a chain of classes), it would be generally referred to as multi-level inheritance. In the case of multi-level inheritance, all the members of all super classes would be automatically available within the sub class.

    Let me extend the classes "first" and "second" with "third" as follows:

    Public Class Third
        Inherits Second

        Public Function getProduct() As Integer
            Dim s As Integer
            s = Me.X * Me.Y * Me.Z
            Return s
        End Function

    End Class

    Now, you can observe that the class "third" is inherited from "second." That means all the members available in the class "second" (all virtual and visual) would be available to the class "third."  In detail, you can observe the following members of the class "third:"

    • M_x (virtual and not accessible)
    • M_y (virtual and not accessible)
    • M_z (virtual and not accessible)
    • X (virtual and accessible)
    • Y (virtual and accessible)
    • Z (virtual and accessible)
    • getSum (virtual and accessible)
    • getProduct (visual and accessible)

    To access the above class, we need to modify the button click event as follows:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim obj As New Third
            With obj
                .X = 10
                .Y = 20
                .Z = 30
                Me.Label1.Text = "Sum = " & .getSum & ", Product = " & .getProduct
            End With
        End Sub

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys. You can have a first look at inheritance in VB.NET 2005 with this...
       · Thanx SirI was completely fresher in programming and was trying to understand OOPS...
       · Pls provide provisiom for running the code
     

    VISUAL BASIC.NET ARTICLES

    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway