What is the difference between the following two statements? I was writing a basic VB.net code which creates a new excel workbook and adds a new sheet. Both seem to be doing the same thing:
Dim oxl As Excel.Application
oxl = New Excel.Application
Dim oxl As Excel.Application
oxl = CreateObject("Excel.Application")
The only thing that I note is that the VB.net editor displays the following message when I am using NEW: "Object initialization can be simplified"
Can anyone pls help?
In the sample code posted the early (or static) binding refers to compile time binding (you must add a COM reference for that):
And late (or dynamic) binding refers to runtime binding (for example when you use reflection) and doesn't require any COM references.
You can read more about early and late binding technologies in the Using early binding and late binding in Automation article.