Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - 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 
Moblin 
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 / 36
    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
     
    Iron Speed
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Inheritance with VB.NET 2005 - Adding your own members to the sub class during inheritance


    (Page 3 of 6 )

    In the previous section, we examined a very simple and basic inheritance. In this section, I shall extend the class "Second" further as follows:

    Public Class Second
        Inherits First

        Private m_z As Integer

        Public Property Z() As Integer
            Get
                Return m_z
            End Get
            Set(ByVal value As Integer)
                m_z = value
            End Set
        End Property

        Public Function getSum() As Integer
            Dim s As Integer
            s = Me.X + Me.Y + Me.Z
            Return s
        End Function
    End Class

    If you observe carefully, the above class contains all the following members:

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

    To work with the above class, I can code the button click as follows:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim obj As New Second
            With obj
                .X = 10
                .Y = 20
                .Z = 30
                Me.Label1.Text = .getSum
            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

    - Movement and Player Statistics in a VB.NET T...
    - 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...




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