Inspection Details

EmptyCaseBlock


Summary
Identifies empty 'Case' blocks that can be safely removed.
Reasoning
Case blocks in VBA do not "fall through"; an empty 'Case' block might be hiding a bug.
The following code example(s) would trigger this inspection:

Public Sub DoSomething(ByVal foo As Long)
    Select Case foo
    Case 0 ' empty block
    Case Is > 0
        Debug.Print foo ' does not run if foo is 0.
    End Select
End Sub

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

Public Sub DoSomething(ByVal foo As Long)
    Select Case foo
    Case 0
        '...code...
    Case Is > 0
        '...code...
    End Select
End Sub


Back to List