Visual Basic.NET
  Home arrow Visual Basic.NET arrow Inheritance with VB.NET 2005
Iron Speed
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 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
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 / 31
    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

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Inheritance with VB.NET 2005
    (Page 1 of 6 )

    This is the beginning of a new series dedicated to explaining inheritance in VB.NET 2005. This article gives you an introduction to inheritance. The upcoming articles will cover some of the advanced aspects of Visual Basic.NET 2005.
    A downloadable file for this article is available here.

    The entire source code for this article is available in the form of downloadable zip.  The solution was developed using Microsoft Visual Studio 2005 Professional Edition on Microsoft Windows Server 2003 Enterprise Edition. Even though I believe that the source code available with this contribution can work with Microsoft Visual Studio.NET 2003/2002, I didn't really test it in any other environment.  I request that you  post in the discussion area if you have any problems with the code's execution.

    Developing a simple class

    My previous articles and series already covered a lot of ground concerning classes, members, fields, methods, properties and so on.  If you are very new to the concept of classes, I suggest you go through my previous series before proceeding with this one.

    For the sake of simplicity in explanation, I developed a simple class as follows:

    Public Class First

        Private m_x As Integer
        Private m_y As Integer

        Public Property X() As Integer
            Get
                Return m_x
            End Get
            Set(ByVal value As Integer)
                m_x = value
            End Set
        End Property

     

        Public Property Y() As Integer
            Get
                Return m_y
            End Get
            Set(ByVal value As Integer)
                m_y = value
            End Set
        End Property

    End Class

    The above class simply contains two fields (m_x and m_y) and two properties (X, Y).  As the fields (m_x and m_y) are defined as private, they are viewable/accessible only within the class "First."  The two properties are mainly used to provide a way to interface with the two fields.

    To work with the above class, you may design a form with a single button and label. The code for the button would be as follows:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim obj As New First
            With obj
                .X = 10
                .Y = 20
                Me.Label1.Text = .X + .Y
            End With
        End Sub

    Within the code above, you can observe that I am creating an object named "obj" based on the class "First." I am assigning values to the properties and retrieving the values from the same, for calculation.

    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

    - 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...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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