Inspection Details

AssignmentNotUsed


Summary
Warns about a variable that is assigned, and then re-assigned before the first assignment is read.
Reasoning
The first assignment is likely redundant, since it is being overwritten by the second.
The following code example(s) would trigger this inspection:

Public Sub DoSomething()
    Dim foo As Long
    foo = 12 ' assignment is redundant
    foo = 34
End Sub

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

Public Sub DoSomething(ByVal foo As Long)
    Dim bar As Long
    bar = 12
    bar = bar + foo ' variable is re-assigned, but the prior assigned value is read at least once first.
End Sub


Back to List