P°echod z VB 6 na Visual Basic .NET

Novß reinstantnost

Visual Basic 6.0

Visual Basic.NET

Upgrade Wizard

Deklarace prom∞nnΘ t°φdy ve form∞ Dim x As New <classname> nutφ kompiler generovat k≤d pro ka₧d² odkaz na x. Tento k≤d testuje, zda je x Nothing; pokud je Nothing, je vytvo°ena novß instance t°φdy. Nap°φklad:

Dim x As New MyClass
'...
Call x.MyMethod()

je ekvivalentnφ:

Dim x As MyClass
'...
If x Is Nothing Then
    Set x = New MyClass
End If
Call x.MyMethod()

Deklarace prom∞nnΘ t°φdy ve form∞ Dim x As New <classname> je ekvivalentnφ deklaraci Dim x As <classname> = New <classname>. Pokud je takto prom∞nnß deklarovßna, negeneruje se ₧ßdn² specißlnφ k≤d p°i referenci na tuto prom∞nou.

Deklarace ve Visual Basic.NET - As New jsou tak daleko vφce efektivn∞jÜφ ne₧ deklarace ve Visual Basic 6.0.

Je lepÜφ ji₧ dop°edu psßt k≤d takto:

Dim x As New MyClass
x = Nothing
x = New MyClass

 Zp∞t

Autor: The Bozena