In addition, a common mistake is to try and create a new object when its not
really needed, for example.
Dim DS As New DataSet("MyDS")
Dim TBL As New DataTable("Table0")
DS.Tables.Add(TBL)
'Sometimes People do this, but it is
'not required because you are creating a new
'object an then throwing that object reference
'away when you assign it to DS.Tables("Table0")
Dim MyTab0 As New DataTable
MyTab0 = DS.Tables("Table0")
'So all you needed to have done is this. . .
'The following do the same job
'*****************************
'This is implicit, takes on the Type returned
Dim MyTab1 = DS.Tables("Table0")
'This is explicit, declares the type
Dim MyTab2 As DataTable = DS.Tables("Table0")
Regards - OHM#
*******************************************************
Armin Zingler wrote:
> "Don" <(E-Mail Removed)> schrieb
>> Thanks Tom. I never seem to know when to use New vs. NOT using
>> New.
>
> Use New whenever you want to create a new object, and the type of the
> object is a reference type. Classes are reference types. Structures
> are value types.
>
> see also:
> http://msdn.microsoft.com/library/en...fVBSpec6_1.asp
Regards - OHM#
(E-Mail Removed)