March 02, 2001

How VB Decides Binding?

VB uses vtable binding when the compiler has enough information about the object to translate a method's name into the actual offset of a slot in the vtable that will contain the address of the compiled routine at run time. VB uses less efficient DispID binding when it can retrieve only the DispID of the method at compile time, using the GetIDsOfName method of the IDispatch interface. All VB-authored ActiveX components support the DispID interface, but you can bypass it using the techniques described in this article for greater ActiveX component performance. DispID's "magic number" is stored in the EXE file, and it is fed to the Invoke method of the IDispatch interface at run time. VB uses late binding if neither method is available: The compiler stores the method's name in the EXE, and the runtime calls the GetIDsOfNames and Invoke methods at run time.