If you're just worried about the Variable 'myVar' is passed by reference before it has been assigned a value
warning, you can just change the declaration to Dim myVar as MyClass = Nothing
.
If you're writing the MyInit
sub, you could also turn it into a function that returns an instance of MyClass
:
Public Function MyInit() As MyClass
Dim myLocalVar As New MyClass()
'... initialization here
Return myLocalVar
End Function
...
Dim myVar As MyClass = MyInit()