-
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
-
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
-
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.
-
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.