alreadyused Posted January 27, 2006 Posted January 27, 2006 (edited) I found this article on MySQL written by Mike Hillyer; http://dev.mysql.com/tech-resources/articles/vb-blob-handling.html Under the topic "Connection Object" Mike states: Connection Object Now that we have a connection string, we can connect to the database, first I will give a sample of how I connect. Dim conn As ADODB.Connection Set conn = New ADODB.Connection conn.ConnectionString = GloConnectionString conn.CursorLocation = adUseClient conn.Open In the first line we create an ADODB connection object in memory and in the second line we instanciate it. The alternative syntax to this is to type Dim conn As New ADODB.Connection While I previously recommended the 'as New' syntax, I have since learned that it slows down your code since it must check if the object is instanciated every time a reference is made to the object. This article is discussing VB6; I interperet this to mean ALL objects instanciated in the declaration will feel this performance hit. But I'm curious, does anyone know if this has been fixed in VB.Net, and if so, is it all versions or only after certain years, such as fixed in 2003 but not 2002? Edited January 27, 2006 by alreadyused Quote
IngisKahn Posted January 27, 2006 Posted January 27, 2006 Yes, thankfully this is fixed in VB.NET Really dumb design in the first place, but then again that "performance hit" is pretty inconsequential. The lines:Dim o As New c Dim o As c = New c are the same. Quote "Who is John Galt?"
alreadyused Posted January 27, 2006 Author Posted January 27, 2006 thanks for the quick reply; so with your example, would the following now be equal to that as well (except for the extra line?) dim o as c o = new c(args) Quote
IngisKahn Posted January 27, 2006 Posted January 27, 2006 Yup, all the same. Quote "Who is John Galt?"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.