5.3.1.7 Property Declarations
Note
This section describes the implementation of MS-VBAL §5.3.1.7 Property Declarations.
Static Semantics
A module's Property Get, Property Let and Property Set sharing a name must together describe one valid
property. Two diagnostics report a property declaration that does not:
| Condition | Example | Diagnostic |
|---|---|---|
A Property Let or Property Set has no parameters, so it has no value parameter to receive what is being assigned. |
Property Let Foo() |
VBC09321 |
Two accessors' index-parameter lists differ in count, name, declared type, or ByRef/ByVal mechanism. |
Property Get Foo(i As Integer) next to Property Let Foo(j As Long, v As Integer) |
VBC09320 |
An index parameter is Optional or a ParamArray, and the property has more than one accessor. |
Property Get Foo(Optional i As Integer) next to Property Let Foo(i As Integer, v As Integer) |
VBC09320 |
Property Let and Property Get sharing a name declare a different value type. |
Property Get Foo() As Long next to Property Let Foo(v As String) |
VBC09320 |
Property Set's value parameter is not Object, Variant, or a named class. |
Property Set Foo(v As Long) |
VBC09320 |
- The index-parameter-equivalence and
Property Setvalue-type conditions of VBC09320 are literal MS-VBAL §5.3.1.7 static-semantics bullets. - Implicit vs. explicit
ByRefon a corresponding index parameter is not a difference: only the actualByRef-vs-ByValmechanism is compared. This matches MS-VBAL §5.3.1.7's own exception for that case. Optional/ParamArrayindex parameters are legal only on a single-accessor property.- A
Property Getneeds no value parameter: it has no value being assigned to it, only (optionally) index parameters to read by. Thevalue-paramrule is described in RD-VBAL §5.3.1.5 Parameter Lists.
Runtime Semantics
- A
Property Gethas a function result variable, as aFunctiondoes: each invocation gets a fresh one, modeled as ICallStackFrame.ReturnValue.Property Getreturn values follow MS-VBAL §5.3.1 Procedure Declarations. See RD-VBAL §5.3.1.6 Subroutine and Function Declarations. - VBVoidType is the data type returned by
Property LetandProperty Setprocedures.
⏮️ RD-VBAL §5.3.1.6 Subroutine and Function Declarations | ⏭️ RD-VBAL §5.3.1.8 Event Handler Declarations