Early and Late Binding
-
Can any body please tell me difference in early and late binding (in VB6) along with example or link.
Basically: with early binding the compiler knows the type of object at compile time. With late binding, the type of object is only known at runtime. There are cases for using one or the other but my preference would be for early binding where possible because many problems and type-related issues can be sorted out during development. If you late bind, some problems may not be evident until your application is live! There are many samples of this on the web - including The Code Project. Simply search for them. In the meantime, very brief samples are shown below...
' Early Binding
' Compiler knows what type x is.Dim x As Word.Application
Set x = New Word.Application' Late Binding:
' Only know what type x is at runtime.Dim x As Object
Set x = CreateObject("Word.Application")...Steve
1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) -
Can any body please tell me difference in early and late binding (in VB6) along with example or link.
In addition to what Steve said, I should add that early-binding is much much faster than late-binding and is the only case to select (unless you HAVE TO use late-binding) for example when you don't have compile-time access to the COM...