Inspection Details

VariableNotAssigned


Summary
Warns about variables that are never assigned.
Reasoning
A variable that is never assigned is probably a sign of a bug. This inspection may yield false positives if the variable is assigned through a ByRef parameter assignment, or if UserForm controls fail to resolve, references to these controls in code-behind can be flagged as unassigned and undeclared variables.
The following code example(s) would trigger this inspection:

Public Sub DoSomething()
    Dim value As Long ' declared, but not assigned
    ' ...
End Sub

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

Public Sub DoSomething()
    Dim value As Long
    value = 42
    ' ...
End Sub


Back to List