Results 1 to 4 of 4

Thread: createobject

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    createobject

    Hi,

    What is the difference between

    dim objXXX as Comp.XXX
    set objXXX = new Comp.XXX

    and

    dim objXXX as Object
    set objXXX = createobject("Comp.XXX")

    ???

    I found that I have two COM from two MTS, I can use either method for one of the COM but only method 2 for the other COM.
    Any idea?

    Thx

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416
    Hi,

    You said the second method is early binding, so what is the difference with this:

    Dim objXXX as CheckBox
    Set objXXX = New CheckBox

    ??

    i.e. what is the difference between Dim as Object and as say CheckBox? I only know that I can't get the method and property list for object dim as Object during programming.

    Thx

  3. #3
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    using New means vb will create the object for you. Using CreateObject, vb will make the COM call (CoCreateObject). You say you can't use the CreateObject call on your other lib.class, this will depend on how the interface to this object is defined. Is it your own object?



    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  4. #4
    Junior Member robinm's Avatar
    Join Date
    May 2001
    Location
    London
    Posts
    19
    Dim MyObject as TextBox
    Set MyObject = New TextBox

    This is early binding and VB knows what type of Object it is
    at design time. You have implicitly stated that it is a textbox, therefore you get access to the objects interfaces...Properties and methods.

    Dim MyObject as Object
    Set MyObject = New TextBox

    This is late bindng. At design time VB has no idea what type of object this is. Therefore you do not get the autocomplete syntax.

    The set does not occur until runtime.

    VB will not instatiate the object until run time. You can manually type the object methods and properties, but the AutoComplete will not appear because VB does not know what the object interfaces are.
    To imitate is human... to copy without recognition is theft.

Posting Permissions

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



Click Here to Expand Forum to Full Width