Name
Public Statement
Syntax
[Overrides] [Shadows] Public [WithEvents]varname[([subscripts])] _ [As [New]type] [, [WithEvents] _varname[([subscripts])][As [New]type]] ...
-
Overrides Use: Optional
Type: Keyword
In a derived class definition, indicates that a variable overrides a similar variable in a base class.
-
Shadows Use: Optional
Type: Keyword
In a derived class definition, indicates that calls to derived class members that are made through a base class ignore the shadowed implementation.
-
WithEvents Use: Optional
Type: Keyword
A keyword that denotes the object variable,
varname, can respond to events triggered from within the object to which it refers.-
varname Use: Required
Type: String literal
The name of the variable, which must follow Visual Basic naming conventions.
-
subscripts Use: Optional
Type: Numeric constant or literal
Denotes
varnameas an array and specifies the dimensions and number of elements of the array.-
New Use: Optional
Type: Keyword
Used to automatically create an instance of the object referred to by the object variable,
varname.-
type Use: Optional
Data type of the variable
varname.
Description
Used at module level to declare a public variable and allocate the relevant storage space in memory.
A Public variable has both project-level scope—that is, it can be used by all procedures in all modules in the project—and, when used in a Class module, it can have scope outside the project.
The Public keyword also applies to procedures and
class modules.
Rules at a Glance ...
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