COM Object Return Multiple Arguments 
Author Message
 COM Object Return Multiple Arguments

How about a SAFEARRAY of Variants...

Building COM Components That Take Full Advantage of Visual Basic and Scripting
http://www.*-*-*.com/

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:
> Hi,
> I'm building an ATL com object and I need to find a way to
> return several parameters from the COM object into an ASP page.
> So far, no luck.
> does anybody know of a good way to return multiple arguments?



Sun, 13 Apr 2003 03:00:00 GMT  
 COM Object Return Multiple Arguments
Hi,
I'm building an ATL com object and I need to find a way to
return several parameters from the COM object into an ASP page.
So far, no luck.
does anybody know of a good way to return multiple arguments?


Mon, 14 Apr 2003 06:34:32 GMT  
 COM Object Return Multiple Arguments


Quote:
> Hi,
> I'm building an ATL com object and I need to find a way to
> return several parameters from the COM object into an ASP page.
> So far, no luck.
> does anybody know of a good way to return multiple arguments?

Your question is very vague...

By "multiple arguments" do you mean a variable number of arguments,
e.g. you need to pass an array back?

The easiest, and most common way of exposing data from INSIDE
the object to the consumer (ASP) is through properties, or
arguments in a method.

For example, let's say you had an ATL object that calculates
MPH based on a given distance (M) and a given time (H).

You would have a method something like this:

STDMETHODIMP CalculateMPH(VARIANT *Distance, VARIANT *ElapsedTime, VARIANT *MPH)

In here, you see that all variables are passed byref, so you don't have
to worry about [in] or [out] or [retval] or anything.

The caller, in ASP would do something like this:
<%
Dim oSpeed
Dim MPH, Hours, Miles

Miles = 60
Hours = 1

Set oSpeed = Server.CreateObject("MyObject.SpeedCalc") 'or whatever
oSpeed.CalculateMPH Miles, Hours, MPH

Response.Write MPH
%>
(the browser would then display 60)

Alternatively, you could have properties in your class, one for
Miles and one for Time and then one for MPH. The consumer (ASP)
would set the properties, then call CalculateMPH with no
arguments and the method would then read all the properties and
work with the data, then populate the MPH property for ASP
to get later.

-Chad



Tue, 15 Apr 2003 01:49:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB COM Object not returning reference argument value

2. COM Object returning multiple values

3. (newbie) returning values from user-defined function using multiple arguments

4. Returning an object with sub objects from vb component (COM) to ASP

5. Passing optional object arguments from COM components

6. idl syntax for object argument or return value

7. COM Object Dynamic Properties / Arguments

8. COM objects as arguments

9. ProcessStartInfo.Arguments - multiple arguments?

10. Using COM objects that return recordsets from JScript

11. JSCript and returning parameters from COM object

12. Capturing return values in JScript from C++ COM objects

 

 
Powered by phpBB® Forum Software