There's a related issue that's good to know about. You can ....
DIM x as SpecificObjectReference
and then you can
either execute...
set x = New SpecificObjectReference
or
set x = createobject("SpecificClass.SpecificObjectReference")
There's an important, but frequently overlooked, distinction between the two approaches to actually creating the object. Many VB programmers believe, mistakenly, that you can only early-bind if you use New. But that's just wrong. It's the method of
declaring the variable that determines whether or not the object is early bound!
However, as far as creating the object, New and CreateObject are not synonymous. If you create an instance of a class that is in the same project as the calling object, the New keyword uses a different and more effective instantiation approach. This is great, UNLESS you are running under MTS. In that case, the new object will not be created using COM/MTS. If you are relying on certain COM features, this can be a problem!
For this reason, since many of my objects are designed to run under COM, I tend to use createobject().
>Use the second method, with the first one there is a performance hit every time you access the object because VB has to check whether the object has already been instanciated.
>
>Roman
>
>>Some objects can be coded as
>>
Dim x As New myObject
>>
>>while some others should be done this way
>>
Dim x as myObject
>>Set x = New myObject
>>
>>How do I know which is which and why the different approach?
>>
>>Just wondering...
>>
>>Tnx Ü
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell