SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 5 - Developing Namespaces in 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

Developing Namespaces in VB.NET 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2006-09-11

    Table of Contents:
  • Developing Namespaces in VB.NET 2005
  • A simple example of a namespace
  • Accessing a class available in a namespace
  • A namespace with more than one class
  • A simple example for a nested namespace
  • Summary

  • 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

    Developing Namespaces in VB.NET 2005 - A simple example for a nested namespace


    (Page 5 of 6 )

    Up until now, we have examined only the outer level namespaces.  Now, let us work with nested namespaces.  A nested namespace (or sub-namespace) is a namespace which exists within another namespace. They can be nested any number of times.

    Let us add one more class file named “Namespace2_third.vb” and modify the code as follows:

    NamespaceNamespace1.Namespace2
        Public Class Third
            Inherits Second
            Public Sub New()
                MyBase.New(0, 0, 0)
            End Sub
            Public Sub New(ByVal a As Integer, ByVal b As Integer,
    ByVal c As Integer)
                MyBase.New(10, 20, 30)
            End Sub
            Public Function getProduct() As Integer
                Dim s As Integer
                s = Me.A * Me.B * Me.C
                Return s
            End Function
        End Class
    EndNamespace

    The most important line to understand from the above code is the following line:

    NamespaceNamespace1.Namespace2

    It shows that we are defining one or more classes for the namespace “Namespace2” which resides in another namespace, “Namespace1.” To access the above class “Third,” I need to modify the code as follows:

    PublicClass Form1
        Private Sub Button1_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles Button1.Click
            Dim obj As New Namespace1.Namespace2.Third(10, 20, 30)
            Me.Label1.Text = obj.getProduct
        End Sub
    EndClass

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys! Expand your knowledge of OOPS to namespaces. thanks and bye
     

    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 5 hosted by Hostway