|
-
May 24th, 2001, 04:57 AM
#1
Thread Starter
Hyperactive Member
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
-
May 24th, 2001, 08:43 PM
#2
Thread Starter
Hyperactive Member
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
-
May 25th, 2001, 03:18 AM
#3
Hyperactive Member
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.
-
May 25th, 2001, 03:44 AM
#4
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|