When declaring an object what is the best method to use, and why.
Example 1:
Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
Example 2:
Dim oConn As New ADODB.Connection
Example 3:
Dim oFSO As New Scripting.FileSystemObject
Dim oTS As Scripting.TextStream
Set oTS = oFSO.OpenTextFile(gLogFile, ForAppending, True, TristateFalse)
I find that I use the method from example 3 the most. Is this ok practice or should I adopt another method? I would appreciate an explanation as to why one method is better than another, if one can be given.
Example 1:
Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
Example 2:
Dim oConn As New ADODB.Connection
Example 3:
Dim oFSO As New Scripting.FileSystemObject
Dim oTS As Scripting.TextStream
Set oTS = oFSO.OpenTextFile(gLogFile, ForAppending, True, TristateFalse)
I find that I use the method from example 3 the most. Is this ok practice or should I adopt another method? I would appreciate an explanation as to why one method is better than another, if one can be given.