user10962741
user10962741

Reputation:

Define a NameSpace in VB

I want to define a unified namespace for all my classes and put them all in it. I did it with

Namespace
...
End Namespace

But now I can not import it in other projects, also I can not import it in another file in my main project (That file is not in my namespace it is just UI).

Thank you in andvance !

Upvotes: 0

Views: 220

Answers (1)

Meta-Knight
Meta-Knight

Reputation: 17845

Your project has a root namespace defined in the project properties. Let's say this root namespace is MyApp.MyProject.

Then inside this project, you have a class defined like this:

Namespace MyNamespace

    Public Class MyClass...

End Namespace

If you want to use MyClass inside another class, you would just add the following Imports statement at the top of the file:

Imports MyApp.MyProject.MyNamespace

You could also define a Namespace globally outside of the root namespace of your project with Global like so:

Namespace Global.MyNamespace
    ...
End Namespace

More information can be found in the .NET documentation

Upvotes: 3

Related Questions