Back

VB047

Collection modified during For Each

Visual Basic 6
Warning
VB6

Removing from a collection while For Each walks it skips elements or raises error 5 mid-loop, whichever the data decides

removing from a collection while For Each walks it skips elements or raises error 5 mid-loop, whichever the data decides.

Why this severity

removing from a collection while For Each walks it skips elements or raises error 5 mid-loop, whichever the data decides.


Known false positives

collection objects whose enumerators tolerate mutation.

Remediation example

For Each key In doomedKeys
    orders.Remove key
Next

Reconnecting… Connection lost. Reload