Search This Blog

Sunday, June 20, 2010

Early Binding Vs Late Binding


Early and Late binding



"An object is early bound when it is assigned to a variable declared to be of a specific object type." (Copied from Microsoft's MSDN page):

“Early” binding was when the assignment of memory locations to variables was done by the compiler.

“Late” binding was when the memory location associated with a variable was not determined until the execution time of the program.
An object is early bound when it is assigned to a variable declared to be of a specific object type. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes.


For Ex:
Dim Objunknowvar as Object



The above variable is said to be "late bound" because the software doesn't really know what kind value will be store in that object variable until runtime when it's actually used for something.



Dim strMyname as string



The above variable is said to be "Early bound". The variable type is know by the compiler and the memory is allocated for the string.

  • The compiler can find errors that might otherwise cause a runtime Application crash.

  • It makes the application to execute faster since code to type conversion from unknown type to the actual type isn't necessary.

  • Intellisense code completion and Dynamic Help only works with early bound variables.


  • Sometimes we need use late binding. When we use COM object (Excel object model) we need to do the late binding and option strict should be off for the late binding. Early binding will increase the application performance. So better to use the really binding later than late binding. Use late binding wherever necessary.

    No comments: