New vs CreateObject 
Author Message
 New vs CreateObject

Actually Charles, you do not have a fully qualified ProgID in your call to CreateObject. It works when using "As New" syntax because VB has already loaded the library and knows where to find MYOBJ (asuming there is no conflict). Use the full ProgID which is:

Set MyObj = CreateObject("<ProjectName>.<ClassName>")

= )

--------------------------------------------------------------------------------

Monte Hansen
VB Yuk Yuk
http://www.*-*-*.com/


  Hi,
  I developed a simple dll and registered in my system. I add in the reference
  of the dll in my new VB application. I have no problem in creating instance
  of the object using New operator. However, I run into error saying unable to
  create ActiveX when I try to use CreateObject.

  set myobj = new MYOBJ         'OK
  set myobj = CreateObject("MYOBJ")    'Error

  Any suggestion?

  Charles



Mon, 22 Jul 2002 03:00:00 GMT  
 New vs CreateObject
Hi,
I developed a simple dll and registered in my system. I add in the reference
of the dll in my new VB application. I have no problem in creating instance
of the object using New operator. However, I run into error saying unable to
create ActiveX when I try to use CreateObject.

set myobj = new MYOBJ         'OK
set myobj = CreateObject("MYOBJ")    'Error

Any suggestion?

Charles



Tue, 23 Jul 2002 03:00:00 GMT  
 New vs CreateObject
It sounds like you DLL didnt register correctly.
Options:
1. Use Regsvr32 and attempt to register the dll.
2. Use the ActiveX Control Test Container and register it that way.
3. Package into a standard setup package and install is that way.

Hope that helps,
Jean

Quote:
> Hi,
> I developed a simple dll and registered in my system. I add in the
reference
> of the dll in my new VB application. I have no problem in creating
instance
> of the object using New operator. However, I run into error saying unable
to
> create ActiveX when I try to use CreateObject.

> set myobj = new MYOBJ         'OK
> set myobj = CreateObject("MYOBJ")    'Error

> Any suggestion?

> Charles



Tue, 23 Jul 2002 03:00:00 GMT  
 New vs CreateObject


Quote:
> Hi,
> I developed a simple dll and registered in my system. I add in the
reference
> of the dll in my new VB application. I have no problem in creating
instance
> of the object using New operator. However, I run into error saying unable
to
> create ActiveX when I try to use CreateObject.

> set myobj = new MYOBJ         'OK
> set myobj = CreateObject("MYOBJ")    'Error

> Any suggestion?

> Charles

CreateObject doesn't use project references, it has to be told where to find
it.

Set myobj = CreateObject("MyComponent.MYOBJ")



Tue, 23 Jul 2002 03:00:00 GMT  
 New vs CreateObject
CreateObject requires "ProjectName.ClassName" as the parameter

You can't just reference the project, as CreateObject ignores your
references and looks in the registry.

Michael Cole


Quote:
> Hi,
> I developed a simple dll and registered in my system. I add in the
reference
> of the dll in my new VB application. I have no problem in creating
instance
> of the object using New operator. However, I run into error saying unable
to
> create ActiveX when I try to use CreateObject.

> set myobj = new MYOBJ         'OK
> set myobj = CreateObject("MYOBJ")    'Error

> Any suggestion?

> Charles



Tue, 23 Jul 2002 03:00:00 GMT  
 New vs CreateObject

Thank you, guys! I got it

Cheers,
Charles

  Actually Charles, you do not have a fully qualified ProgID in your call to CreateObject. It works when using "As New" syntax because VB has already loaded the library and knows where to find MYOBJ (asuming there is no conflict). Use the full ProgID which is:

  Set MyObj = CreateObject("<ProjectName>.<ClassName>")

  = )

------------------------------------------------------------------------------

  Monte Hansen
  VB Yuk Yuk
  http://KillerVb.com


    Hi,
    I developed a simple dll and registered in my system. I add in the reference
    of the dll in my new VB application. I have no problem in creating instance
    of the object using New operator. However, I run into error saying unable to
    create ActiveX when I try to use CreateObject.

    set myobj = new MYOBJ         'OK
    set myobj = CreateObject("MYOBJ")    'Error

    Any suggestion?

    Charles



Wed, 24 Jul 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. New Vs CreateObject

2. CreateObject VS New

3. CreateObject vs New

4. New vs. CreateObject

5. strange problem: createobject vs new

6. CreateObject vs New, with Implements ObjectControl

7. CreateObject vs. New

8. New vs. CreateObject

9. CreateObject vs New

10. CreateObject vs New keyword in COM+

11. new ActiveXObject() vs. Server.CreateObject()

12. CreateObject vs. New

 

 
Powered by phpBB® Forum Software