Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

6. Source Files and Namespaces

Visual Studio .NET 2003

A Visual Basic .NET program consists of one or more source files. When a program is compiled, all of the source files are processed together; thus, source files can depend on each other, possibly in a circular fashion, without any forward-declaration requirement. The textual order of declarations in the program text is generally of no significance.

A source file consists of an optional set of option statements, import statements, and attributes, which are followed by a namespace body. The attributes, which must each have either the Assembly or Module modifier, apply to the .NET assembly or module produced by the compilation. The body of the source file functions as an implicit namespace declaration for the global namespace, meaning that all declarations at the top level of a source file are placed in the global namespace. For example:

File A.vb:
    Class A
    End Class

File B.vb:
    Class B
    End Class

The two source files contribute to the global namespace, in this case declaring two classes with the fully qualified names A and B. Because the two source files contribute to the same declaration space, it would have been an error if each contained a declaration of a member with the same name.

The compilation environment may override the namespace declarations into which a source file is implicitly placed.

Start ::=
   [ OptionStatement+ ]
   [ ImportsStatement+ ]
   [ Attributes ]
   [ NamespaceMemberDeclaration+ ]

See Also

6.2 Compilation Options | 6.3 Imports Statement | 6.4 Namespaces | Namespace Statement (Visual Basic Language Reference) | Namespaces (Visual Basic Language Concepts)

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.