Problem calling a method of a COM object with VB 
Author Message
 Problem calling a method of a COM object with VB

I've a COM object, written in C++, which have one property and one method.
The method called "calc" accepts one input parameter of type "long", and
another one of the same type "long", as output parameter. here follows the
IDL declaration of the "calc" method:
[id(1), helpstring("multiplies for 2")] HRESULT calc([in] long lValue, [out]
long* lRetValue);

Now I'd like to use this component using a VB application as client. If I
instantiate the component using the CreateObject function (so using
Automation), the server can be used successfully, with no problem.
But I'd obviously like to use the component's type library, and to call
directly the method. After have included the type library into the VB
project, I've instantiate the component using new instead, and this works
well.
Now I want to call the method "calc", but I don't know if the ret parameter
"IRetValue" have to be explicitly passed to method as actual parameter, or
if VB incapsulates the calling to method, and returns the ret parameter as
return value.
I tryed these calling sintax, with no success:

' sintax 1:
val=component.calc(10)

' sintax 2:
dim ret as long
val=component.calc(10, ret) ' sintax 2

Any help would be appreciated !



Sun, 09 Feb 2003 03:00:00 GMT  
 Problem calling a method of a COM object with VB
For use return value in VB.

declare the return parameter in IDL as follow

[out, retval] long* lRetValue.
      ^

Then , in VB, use

val=component.calc(10)

Quote:
>I've a COM object, written in C++, which have one property and one method.
>The method called "calc" accepts one input parameter of type "long", and
>another one of the same type "long", as output parameter. here follows the
>IDL declaration of the "calc" method:
>[id(1), helpstring("multiplies for 2")] HRESULT calc([in] long lValue, [out]
>long* lRetValue);

>Now I'd like to use this component using a VB application as client. If I
>instantiate the component using the CreateObject function (so using
>Automation), the server can be used successfully, with no problem.
>But I'd obviously like to use the component's type library, and to call
>directly the method. After have included the type library into the VB
>project, I've instantiate the component using new instead, and this works
>well.
>Now I want to call the method "calc", but I don't know if the ret parameter
>"IRetValue" have to be explicitly passed to method as actual parameter, or
>if VB incapsulates the calling to method, and returns the ret parameter as
>return value.
>I tryed these calling sintax, with no success:

>' sintax 1:
>val=component.calc(10)

>' sintax 2:
>dim ret as long
>val=component.calc(10, ret) ' sintax 2

>Any help would be appreciated !

Jacky Kwok





Mon, 10 Feb 2003 09:36:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Call VB DLL or COM object from within VB COM object or EXE

2. Calling a COM call back object's method fails if it is in Windows 98

3. com object will not read registry when com object called from asp (vb works fine)

4. Problem to call a method on COM with VB

5. Performance of ASP pages calling COM object methods

6. Maybe a newbie question : Howto have a timeout on a COM Object method call

7. Performance of ASP pages calling COM object methods

8. Calling COM methods from VB with modified parameters

9. VB COM object methods

10. Problems calling method in shockwave object in another window

11. Calling a COM object from VB.Net with Optional Params

12. call com object with byref byte parameters in vb.net

 

 
Powered by phpBB® Forum Software