+ Reply to Thread
Results 1 to 5 of 5

Late Binding or Late Anything

  1. #1
    Forum Contributor
    Join Date
    02-26-2005
    Posts
    175

    Late Binding or Late Anything

    Hi,

    The phrase "Late Binding". I also heard something about "Late" in reference to a formula.

    What does it mean?
    How do you use it?
    Why would you use it?
    When would you use it?

    Explaination or a reference to a place where i can get info about this would be much appreciated.

    thx
    Call me Late for anything but dinner.
    Dave

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hi Piranha,

    It's a term relating to assigning object variables. Here is some info from the Microsoft Developers Network Site (MSDN) that should help you.

    The Visual Basic compiler performs a process called binding when an object is assigned to an object variable. 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.

    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.

    You should use early-bound objects whenever possible, because they allow the compiler to make important optimizations that yield more efficient applications. Early-bound objects are significantly faster than late-bound objects and make your code easier to read and maintain by stating exactly what kind of objects are being used. Another advantage to early binding is that it enables useful features such as automatic code completion and Dynamic Help because the Visual Studio .NET integrated development environment (IDE) can determine exactly what type of object you are working with as you edit the code. Early binding reduces the number and severity of run-time errors because it allows the compiler to report errors when a program is compiled.

    Note Late binding can only be used to access type members that are declared as Public. Accessing members declared as Friend or Protected Friend results in a runtime error.

    Hope this answers your questions,
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    JMB
    Guest

    RE: Late Binding or Late Anything

    I don't know all there is on the subject, but

    late binding requires the computer to determine what specific data type (and
    properties/methods for that data type) you are using at run time, instead of
    when the code is compiled.

    You could declare a variable as an object, then associate it with a range
    (late binding). Or, declare the variable as a range (early binding) in your
    Dim statement.

    As an example of late binding, you could declare a variable as an object,
    then in your code set it equal to the Word Application.

    Alternatively, w/early binding you would set up a reference to Word through
    VBA's Tools/References menu, then declare your object variable as the Word
    Application in your Dim statement. One advantage is this enables Excel's
    Intellisense when you try to use Word methods and properties in your VBA code.

    If I remember correctly, one possible advantage to late binding is you could
    check for the presence of Word Application before associating the object
    variable w/Word (or trap the error when you try to bind the object variable).
    With early binding, I believe you would get a compile error before you could
    try to trap the error.




    "Piranha" wrote:

    >
    > Hi,
    >
    > The phrase "Late Binding". I also heard something about "Late" in
    > reference to a formula.
    >
    > What does it mean?
    > How do you use it?
    > Why would you use it?
    > When would you use it?
    >
    > Explaination or a reference to a place where i can get info about this
    > would be much appreciated.
    >
    > thx
    > Call me Late for anything but dinner.
    > Dave
    >
    >
    > --
    > Piranha
    > ------------------------------------------------------------------------
    > Piranha's Profile: http://www.excelforum.com/member.php...o&userid=20435
    > View this thread: http://www.excelforum.com/showthread...hreadid=476077
    >
    >


  4. #4
    trooper665
    Guest

    Re: Late Binding or Late Anything

    One other benefit of late-binding that is not mentioned is that you do not
    need to recompile your code if the object that you are referencing has
    changed. If you use early binding you do need to recompile your code every
    time your referenced object is updated.

    Jeff

    "Leith Ross" wrote:

    >
    > Hi Piranha,
    >
    > It's a term relating to assigning object variables. Here is some info
    > from the Microsoft Developers Network Site (MSDN) that should help
    > you.
    >
    > The Visual Basic compiler performs a process called binding when an
    > object is assigned to an object variable. 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.
    >
    > 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.
    >
    > You should use early-bound objects whenever possible, because they
    > allow the compiler to make important optimizations that yield more
    > efficient applications. Early-bound objects are significantly faster
    > than late-bound objects and make your code easier to read and maintain
    > by stating exactly what kind of objects are being used. Another
    > advantage to early binding is that it enables useful features such as
    > automatic code completion and Dynamic Help because the Visual Studio
    > .NET integrated development environment (IDE) can determine exactly
    > what type of object you are working with as you edit the code. Early
    > binding reduces the number and severity of run-time errors because it
    > allows the compiler to report errors when a program is compiled.
    >
    > Note Late binding can only be used to access type members that are
    > declared as Public. Accessing members declared as Friend or Protected
    > Friend results in a runtime error.
    >
    > Hope this answers your questions,
    >
    >
    > --
    > Leith Ross
    >
    >
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=476077
    >
    >


  5. #5
    Forum Contributor
    Join Date
    02-26-2005
    Posts
    175
    Gentlemen,
    Leith, JMB, trooper665,

    Thx so much for the in depth explanation of this subject. Its more than i hoped for.

    Thx Very much
    Dave
    Quote Originally Posted by Leith Ross
    Hi Piranha,

    It's a term relating to assigning object variables. Here is some info from the Microsoft Developers Network Site (MSDN) that should help you.

    The Visual Basic compiler performs a process called binding when an object is assigned to an object variable. 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.

    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.

    You should use early-bound objects whenever possible, because they allow the compiler to make important optimizations that yield more efficient applications. Early-bound objects are significantly faster than late-bound objects and make your code easier to read and maintain by stating exactly what kind of objects are being used. Another advantage to early binding is that it enables useful features such as automatic code completion and Dynamic Help because the Visual Studio .NET integrated development environment (IDE) can determine exactly what type of object you are working with as you edit the code. Early binding reduces the number and severity of run-time errors because it allows the compiler to report errors when a program is compiled.

    Note Late binding can only be used to access type members that are declared as Public. Accessing members declared as Friend or Protected Friend results in a runtime error.

    Hope this answers your questions,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1