Hi I was just sent an article regarding optimisation of code by a colleague. The article is actually for VB6 (something I think they overlooked) but one statement in it has got me to wondering.
This comes from http://www.aivosto.com/vbtips/not-optimize.html
I was just wondering if this statement if true, is also true of VB.NET?
Thanks
Don't Dim .. As New
Dim obj As MyClass
Set obj = New MyClass
Why write 2 lines when you can just say Dim obj As New MyClass?
Never Dim anything As New if you're concerned about speed. VB6 will treat such a variable as an auto-instantiated variable. Every time you use it, VB will check if it should be instantiated. This will cost you some extra CPU cycles.
This comes from http://www.aivosto.com/vbtips/not-optimize.html
I was just wondering if this statement if true, is also true of VB.NET?
Thanks