5.2.3.3 User Defined Type Declarations
-
public-type-declaration = ["global" / "public"] udt-declaration private-type-declaration = "private" udt-declaration udt-declaration = "type" untyped-name EOS udt-member-list EOS "end" "type" udt-member-list = udt-element *[EOS udt-element] udt-element = rem-statement / udt-member udt-member = reserved-name-member-dcl / untyped-name-member-dcl untyped-name-member-dcl = IDENTIFIER optional-array-clause reserved-name-member-dcl = reserved-member-name as-clause optional-array-clause = [array-dim] as-clause reserved-member-name = statement-keyword / marker-keyword / operator-identifier / special-form / reserved-name / literal-identifier / reserved-for-implementation-use / future-reserved
-
Static Semantics
The UDT name of the containing <udt-declaration> is the name value of the <untyped-name> that follows the Type keyword (section 3.3.5.1).
Each <udt-declaration>defines a unique declared type and unique UDT value type each of which is identified by the UDT name.
A UDT declaration that is part of a <public-const-declaration> declares a public UDT. The UDT is accessible within the enclosing project. If the enclosing module is a procedural module that is not a private module, then the UDT is also accessible within projects that reference the enclosing project.
A UDT declaration that is part of a <private-const-declaration> declares a private UDT. The UDT is accessible within the enclosing module.
If an <udt-declaration> is an element of a <private-type-declaration> its UDT name cannot be the same as the enum name of any <enum-declaration> or the UDT name of any other <udt-declaration> within the same module.
If an <udt-declaration> is an element of a <public-type-declaration> its UDT name cannot be the same as the enum name of a public <enum-declaration> or the UDT name of any <public-type-declaration> within any module of the project that contains it.
If an <udt-declaration> is an element of a <public-type-declaration> its UDT name cannot be the same as the name of any project or library within the current VBA Environment or the same name as any module within the project that contains the <udt-declaration>.
The name value of a <reserved-member-name> is the text of its reserved identifier name. At least one <udt-element> in a <udt-member-list> MUST consist of a <udt-member>.
If a <udt-member> is an <untyped-name-member-dcl> its udt member name is the name value of the <IDENTIFIER> element of the <untyped-name-member-dcl>.
If a <udt-member> is a <reserved-name-member-dcl> its udt member name is the name value of the <reserved-member-name> element of the <reserved-name-member-dcl>.
Each <udt-member> within a <udt-member-list> MUST have a different udt member name.
Each <udt-member> defines a named element of the UDT value type identified by the UDT name of the containing <udt-declaration>.
Each <udt-member> defines a named element of the UDT value type and declared type identified by the UDT name of the containing <udt-declaration>.
The declared type of the UDT element defined by a <udt-member> is defined as follows:
If the <udt-member> contains an <array-dim> that does not contain a <bounds-list>, then the declared type of the UDT element is resizable array with a declared element type is the specified type of the <as-clause> contained in the <udt-member>.
If the <udt-member> contains an <array-dim> that contains a <bounds-list>, then the declared type of the UDT element is fixed size array whose declared element type is the specified type of the <as-clause> contained in the <udt-member>. The number of dimensions and the upper and lower bound for each dimension is as defined by the <bounds-list>.
Otherwise the declared type of the UDT element is the specified type of the <as-clause>.
If a <udt-member> contains an <as-clause> that consists of an <as-auto-object> then the corresponding dependent variable (or each dependent variable of an array variable) of any variable whose declared type is the UDT name of the containing <udt-declaration> is an automatic instantiations variable.