Understanding the answer to this question means understanding the difference between early binding and late binding. When you use the "New" keyword, you are telling VB exactly what kind of object you are going to use in your program such as:
dim objRS as New Recordset
Visual Basic now knows that objRS is a recordset and thus can include the proper object linking when the program is compiled. This is called early binding and is a bit faster at run time. It also allows the compiler to catch syntax errors when using the object's methods and properties.
However,
dim objRS as object
set objRS = CreateObject("ADODB.Recordset"
.. is late binding. When compiling, VB doesn't know what objRS is, that is resolved at run time.
In practice, only use late binding when necessary.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.