Name
Module...End Module Statement
Syntax
accessmodifierModulemodulename' statementsEnd Module
-
accessmodifier Use: Optional
Type: Keyword
One of the following keywords determine the visibility of the module:
-
Public Makes the module visible to all applications
-
Friend Makes the module visible throughout the project
-
modulename Use: Required
Type: String literal
The name of the code module
Description
Defines a code block as a code module
Rules at a Glance
If
accessmodifieris omitted, the module isPublicby default.modulenamefollows standard Visual Basic naming conventions and must be unique within its assembly.statementscan consist of the following:Constant and variable definitions
Function and procedure definitions
Programming Tips and Gotchas
Internally, code modules are implemented as classes. Their public variables are treated as static fields, and their public functions and procedures are treated as static (shared) methods. This means that, particularly in the event of a naming conflict (where two routines in different code modules have the same name), you can qualify the function or procedure with the name of the module in which it resides. For example, if the SayHello procedure is found in a module named modLibrary, it can be called as follows:
modLibrary.SayHello( )
If a code module is to contain a routine that serves as a program entry point, that routine must be named
SubMain. It must also have Public scope.
VB .NET/VB 6 Differences
The statement is new to VB .NET. VB 6 placed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access