Inspection Details

ValueRequired


Summary
Locates places in which a value needs to be accessed but an object variables has been provided that does not have a suitable default member.
Reasoning
The VBA compiler does not check whether the necessary default member is present. Instead there is a runtime error whenever the runtime type fails to have the default member.
The following code example(s) would trigger this inspection:

Class1:
Public Function Foo() As Long
    'No default member attribute
End Function
------------------------------
Module1:
Public Sub DoIt()
    Dim cls As Class1
    Dim bar As Variant
    Set cls = New Class1
    bar = cls + 42
End Sub

The following code example(s) would not trigger this inspection:

Class1:
Public Function Foo() As Long
    Attribute Foo.UserMemId = 0
End Function
------------------------------
Module1:
Public Sub DoIt()
    Dim cls As Class1
    Dim bar As Variant
    Set cls = New Class1
    bar = cls + 42
End Sub


Back to List