Back

VB038

As New auto-instancing

Visual Basic 6
Warning
VB6

Dim x As New re-creates the object the moment it is touched after Set x = Nothing, so lifetime checks lie and teardown code resurrects what it released

Dim x As New re-creates the object the moment it is touched after Set x = Nothing, so lifetime checks lie and teardown code resurrects what it released.

Why this severity

Dim x As New re-creates the object the moment it is touched after Set x = Nothing, so lifetime checks lie and teardown code resurrects what it released.


Known false positives

code that deliberately relies on auto-instancing.

Remediation example

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection

Reconnecting… Connection lost. Reload