Board index » delphi » How to create COM client object in VB - Urgent

How to create COM client object in VB - Urgent

Hi,

I have problems in create com object in VB 6.

My VB code:
   dim myobj As object
   Set myobj = CreateObject("MyComSvr.MyComServer")
   Label1.Caption = myobj.ShowVersion()

the error message "Object Required" shown me when i try to create the
object.

However,
I try with this code also
   dim myobj As MyComSvr.MyComServer
   Set myobj = CreateObject("MyComSvr.MyComServer")
   Label1.Caption = myobj.ShowVersion()

I get another error message and my program terminate imediately once i try
to invoke the ShowVersion method.

I do have another client write in Delphi 5. It works fine.

can anyone pinpoint me what should i do to make it works?

Thanks in advance

Quek

 

Re:How to create COM client object in VB - Urgent


<<Quek:
the error message "Object Required" shown me when i try to
create the object.

Quote

Can you tell us anything about MyComSvr.MyComServer?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:How to create COM client object in VB - Urgent


Deborah,

    Thanks for your reply.

    For your information, My ComSvr.MyComServer is TTypedComObject. Which
only contain a single function as below.

function TMyComServer.ShowVersion: WideString;
begin
   Result := 'Version 1.0.1';
end;

I am using the Active X library and ComObject Wizard to generate this COM
Server. It is running in Window 2000 Pro.

A type library file is generated too.

Re:How to create COM client object in VB - Urgent


<<Quek:
My ComSvr.MyComServer is TTypedComObject.

Quote

That explains the 'object required' error, I think, since
declaring something as 'object' means late binding, AFAIK,
which needs an IDispatch interface, and TTypedComObject
inherits from IUnknown. What error message do you get with
the second code snippet you gave?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:How to create COM client object in VB - Urgent


Dear Deborah,

This is the error message i get in the second code snippet.

Error Message: The exception unknown software exception (0x0eedfade)
occurred in the
                        application

Thanks.

Quek.

Re:How to create COM client object in VB - Urgent


You'll need to switch to TAutoObject. Late binding requires IDispatch to
work. If you don't want late-binding, you can early-bind in VB:

First, add a reference to your Delphi COM server in VB: Project | References

dim MyObj as IMyComServer
set MyObj = new MyComServer 'or CreateObject (...)
x = MyObject.ShowVersion

--
have fun

Binh Ly
www.techvanguards.com

Quote
"Quek" <q...@dbix.com.my> wrote in message news:3ae385d2_1@dnews...
> Deborah,

>     Thanks for your reply.

>     For your information, My ComSvr.MyComServer is TTypedComObject. Which
> only contain a single function as below.

> function TMyComServer.ShowVersion: WideString;
> begin
>    Result := 'Version 1.0.1';
> end;

> I am using the Active X library and ComObject Wizard to generate this COM
> Server. It is running in Window 2000 Pro.

> A type library file is generated too.

Re:How to create COM client object in VB - Urgent


Thanks, Binh.

Quote
"Binh Ly" <b...@castle.net> wrote in message news:3ae64c2f$2_2@dnews...
> You'll need to switch to TAutoObject. Late binding requires IDispatch to
> work. If you don't want late-binding, you can early-bind in VB:

> First, add a reference to your Delphi COM server in VB: Project |
References

> dim MyObj as IMyComServer
> set MyObj = new MyComServer 'or CreateObject (...)
> x = MyObject.ShowVersion

> --
> have fun

> Binh Ly
> www.techvanguards.com

> "Quek" <q...@dbix.com.my> wrote in message news:3ae385d2_1@dnews...
> > Deborah,

> >     Thanks for your reply.

> >     For your information, My ComSvr.MyComServer is TTypedComObject.
Which
> > only contain a single function as below.

> > function TMyComServer.ShowVersion: WideString;
> > begin
> >    Result := 'Version 1.0.1';
> > end;

> > I am using the Active X library and ComObject Wizard to generate this
COM
> > Server. It is running in Window 2000 Pro.

> > A type library file is generated too.

Other Threads