Interviews1 answer
Write one code example for compile time binding and one for run time binding?what is early/late binding?
1 Answer
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.
‘ Create a variable to hold a new object.
Dim FS As FileStream
‘ Assign a new object to the variable.
FS = New FileStream(”C:\tmp.txt”, FileMode.Open)
By contrast, an object is late bound when it is assigned to a variable declared to be of type Object. Objects of this type can hold references to any object, but lack many of the advantages of early-bound objects.
Dim xlApp As Object
xlApp = CreateObject(”Excel.Application”)
Samir BhogaytaPosted Jun 25, 2016, 1:06 AM EDT
