Table of Contents

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 Set value-type conditions of VBC09320 are literal MS-VBAL §5.3.1.7 static-semantics bullets.
  • Implicit vs. explicit ByRef on a corresponding index parameter is not a difference: only the actual ByRef-vs-ByVal mechanism is compared. This matches MS-VBAL §5.3.1.7's own exception for that case.
  • Optional/ParamArray index parameters are legal only on a single-accessor property.
  • A Property Get needs no value parameter: it has no value being assigned to it, only (optionally) index parameters to read by. The value-param rule is described in RD-VBAL §5.3.1.5 Parameter Lists.

Runtime Semantics


⏮️ RD-VBAL §5.3.1.6 Subroutine and Function Declarations | ⏭️ RD-VBAL §5.3.1.8 Event Handler Declarations