VB Creating User-Defined Namespaces


1. Open the VB.NET Interface

2. Go to:-File-New-Project-WindowApplication1

3. Add new Item(Go to Project?Add Module)

4. In Module.vb add the following code:-

Namespace dc
        Public Class x
            Public Sub hj()
            End Sub
        End Class
  End Namespace

5. Now Debug the application so that its .exe or .dll file can be created.

6. Open a new project WindowApplication2

7. Now in order to add reference of the namespace created in WindowApplication1 to the current project, go to


By following these steps namespaces defined in this exe will get accessible in the current project.

Next, Go to Coding part of Form i.e.Form1.vb and do write at the top:-Imports WindowApplication.dc, where jk is the namespace name.

Go to form load event and create a new instance(object) of the class defined inside the jk namespace

For performing step no 10 write coding such as:-Dim s as new x where x is the class defined inside the namespace dc.

Now, in order to access the methods defined in this class write the following code such as:-

s.hj(),where hj() is the method displaying message hello.

Share this article on