Wednesday, October 17, 2007

Dim x As new as opposed to set x = new...

Just a really old tip I once got - so old I couldn't remember why, until today when I wanted to explain why I did it this way...

Dim x as myObject
set x = new myObject

Rather than,
Dim x as new myObject


The former is more efficient as, using the later, the compiler will need to insert heaps of code around the "x" object each time it is used.

See this link for an elegant expalnation http://visualbasic.ittoolbox.com/groups/technical-functional/visualbasic-l/adodb-creating-new-94396

No comments:

Post a Comment