Public [WithEvents] varname[([subscripts])] _ [As [New] type] [, [WithEvents] _ varname[([subscripts])] [As [New] type]] . . .
A keyword that denotes the object variable varname can respond to events triggered from within the object to which it refers.
Data Type: Any
The name of the variable, which must follow Visual Basic naming conventions.
Denotes varname as an array and specifies the dimensions and number of elements of the array.
Used to automatically create an instance of the object referred to by the object variable varname.
Data type of the variable varname.
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 behavior of a Public variable depends on where it's declared, as the following table shows:
|Variable Declared in...||Scope|
|Any procedure||Illegal; generates a compile-time error.|
|Code module declarations section||Variable is available to all modules within the project.|
|Class module declarations section||Variable is available as a property of the class to all modules within the project, and to all other projects referencing ...|