Visual Basic Language Reference  

Module Statement

Declares a module block.

[ <attrilist> ] [ Public | Friend ] Module name
   [ statements ]
End Module

Parts

attrlist
Optional. List of attributes that apply to this module. Multiple attributes are separated by commas.
Public
Optional. Modules declared with the Public keyword have public access. There are no restrictions on the accessibility of public modules.
Friend
Optional. Modules declared with the Friend keyword have friend access. They are accessible from within the program that contains their declaration and from anywhere else in the same assembly. Modules that do not specify an access modifier are declared as Friend by default.
name
Required. Name of the module. Must be a valid Visual Basic identifier.
statements
Optional. Statements that comprise the variables, properties, events, and methods of the module.
End Module
Terminates a Module block.

Each attribute in the attrlist part has the following syntax and parts:

attrname [({ attrargs | attrinit })]

attrlist Parts

attrname
Required. Name of the attribute. Must be a valid Visual Basic identifier.
attrargs
Optional. List of positional arguments for this attribute. Multiple arguments are separated by commas.
attrinit
Optional. List of field or property initializers for this attribute. Multiple initializers are separated by commas.

Remarks

Modules are a reference type similar to classes, but with some important distinctions. The members of a module are implicitly Shared and scoped to the declaration space of the standard module's containing namespace, rather than just to the module itself. Unlike classes, modules can never be instantiated, do not support inheritance, and cannot implement interfaces. A module can only be declared in a namespace and cannot be nested in another type.

You can have multiple modules in a project, but members with the same name defined in two or more modules must be qualified with their module name when accessed outside of their module.

Example

Public Module Module1
   ' Add classes, properties, methods, fields, and events for this module.
End Module

See Also

Class Statement | Namespace Statement | Property Statement