Inspection Details

UseOfBangNotation


Summary
Identifies the use of bang notation, formally known as dictionary access expression.
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.
The following code example(s) would trigger this inspection:

Public Sub DoSomething(ByVal wkb As Excel.Workbook)
    wkb.Worksheets!MySheet.Range("A1").Value = 42
End Sub

Public Sub DoSomething(ByVal wkb As Excel.Workbook)
    With wkb.Worksheets
        !MySheet.Range("A1").Value = 42
    End With
End Sub

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

Public Sub DoSomething(ByVal wkb As Excel.Workbook)
    wkb.Worksheets("MySheet").Range("A1").Value = 42
End Sub

Public Sub DoSomething(ByVal wkb As Excel.Workbook)
    wkb.Worksheets.Item("MySheet").Range("A1").Value = 42
End Sub

Public Sub DoSomething(ByVal wkb As Excel.Workbook)
    With wkb.Worksheets
        .Item("MySheet").Range("A1").Value = 42
    End With
End Sub


Back to List