Inspection Details

UseOfRecursiveBangNotation


Summary
Identifies the use of bang notation, formally known as dictionary access expression, for which a recursive default member resolution is necessary.
Reasoning
A dictionary access expression looks like a strongly typed call, but it actually is a stringly typed access to the parameterized default member of the object. This is especially misleading if the parameterized default member is not on the object itself and can only be reached by calling the parameterless default member first.
The following code example(s) would trigger this inspection:

Public Function MyName(ByVal rst As ADODB.Recordset) As Variant
    MyName = rst!Name.Value
End Function

Public Function MyName(ByVal rst As ADODB.Recordset) As Variant
    With rst
        MyName = !Name.Value
    End With
End Function

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

Public Function MyName(ByVal rst As ADODB.Recordset) As Variant
    MyName = rst.Fields.Item("Name").Value
End Function

Public Function MyName(ByVal rst As ADODB.Recordset) As Variant
    MyName = rst("Name").Value
End Function

Public Function MyName(ByVal rst As ADODB.Recordset) As Variant
    MyName = rst.Fields!Name.Value 'see "UseOfBangNotation" inspection
End Function

Public Function MyName(ByVal rst As ADODB.Recordset) As Variant
    With rst
        MyName = .Fields.Item("Name").Value
    End With
End Function


Back to List