Name
Dim Statement
Syntax
[Overrides] [Shadows] Dim [WithEvents]varname[([subscripts])]_ [As [New]type] [= initexpr]
-
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
In an object variable definition, indicates that the object will receive event notification
-
varname Use: Required
Your chosen name for the variable
-
subscripts Use: Optional
Dimensions of an array variable
-
New Use: Optional
Type: Keyword
Keyword that creates an instance of an object
-
type Use: Optional
The data type of
varname-
initexpr Use: Optional
Any expression that provides the initial value to assign to the variable; cannot be used if an
AsNewclause is used
Description
Declares and allocates storage space in memory for variables. The
Dim statement is used either at the start of a
procedure or the start of a module to declare a variable of a
particular data type.
Rules at a Glance
Object is the default data type created when no data type is explicitly declared.
The declaration of a nonobject variable actually creates the variable. For an object variable, the variable is not created unless the optional
Newstatement is used. If not, then the object variable is set toNothingand must be assigned a reference to an ...
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