"Ronald S. Cook" <rc***@westinis.comwrote in message
news:Oh**************@TK2MSFTNGP04.phx.gbl...
So most of the time I need to write the following to instantiate an
object:
Dim cnn As New SqlConnection()
But sometimes Intellisense tells me not to include the "new":
Dim dst As DataSet
When do I use "As New" and when don't I? Intellisense is good at letting
me know which is correct, but I'd like to understand better.
Dim x as Gizmo
this creates a variable named x that can reference an object of type Gizmo
at this point, however, x does not reference an object (its a null pointer)
x = new Gizmo()
this calls the constructor of the Gizmo class and now the variable x
references an object of type Gizmo.
the sub named new 'instantiates' an object of the class.
HTH