This documentation is archived and is not being maintained.

Module Statement

Declares a module block.

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


Optional. List of attributes that apply to this module. Multiple attributes are separated by commas.
Optional. Modules declared with the Public keyword have public access. There are no restrictions on the accessibility of public modules.
Optional. Modules declared with the Friend keyword have friend access. They are accessible from within their declaration context and from anywhere else in the same program. Modules that do not specify an access modifier are declared as Friend by default.
Required. Name of the module. Must be a valid Visual Basic identifier.
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

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


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.


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

See Also

Class Statement | Namespace Statement | Property Statement