Visual Basic.NET
  Home arrow Visual Basic.NET arrow 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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 47
    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


    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
       · The final example with of the constructor inheritance should be MyBase.New(a,b,c) It...
       · I agree that it would be best to pass the parameters in but overall it was a good...
     

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek