Re: How to Pass a SafeArray of UDT's as VARIANT
From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 12/14/04
- Next message: Alexander Nickolov: "Re: Destroy the parent of the control"
- Previous message: Alexander Nickolov: "Re: Global Method"
- In reply to: BigFish: "How to Pass a SafeArray of UDT's as VARIANT"
- Next in thread: Igor Tandetnik: "Re: How to Pass a SafeArray of UDT's as VARIANT"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Dec 2004 09:35:48 -0800
Check if your UDT is output in the generated type library.
I suspect it's not. Therefore, you need to write a little IDL
to define it there, build the type library out of it, then use it
within VB. Note, VB's UDTs are by default private.
Also, see this FAQ article:
http://www.mvps.org/vcfaq/com/4.htm
-- ===================================== Alexander Nickolov Microsoft MVP [VC], MCSD email: agnickolov@mvps.org MVP VC FAQ: http://www.mvps.org/vcfaq ===================================== "BigFish" <BigFish@newsgroup.nospam> wrote in message news:O4zA8j63EHA.2316@TK2MSFTNGP15.phx.gbl... >I want to pass a safearray of UDT's as VARIANT so the safearray can be an > optional parameter when passed from VB. When my method is called with no > parameter, I get a VARIANT with vt = VT_ERROR / DISP_E_PARAMNOTFOUND which > is correct. But when I pass with a safearray of UDT's I get vt = VT_ARRAY > | > VT_BYREF | VT_VOID and my safearray is wacked. The UDT has long's and > BSTR's > and the number of elements in the safearray can vary depending upon the > number of data points in a given sample. I think my IDL is wrong. Anybody > know how to do this? > > My IDL: > [id(15), helpstring("method doProcess")] HRESULT doProcess([in, optional] > VARIANT* pVArray); > > My VB: > Dim ProcessData(0 To 2) As myObject.UDTVar > ProcessData(0).Pressure = 10 > ProcessData(0).Location = "Southside Facility" > etc... > 'safearray passed > myObject.doProcess ProcessData > > ends up with vt = VT_ARRAY | VT_BYREF | VT_VOID and my safearray is wacked > > 'and for no parameter: > myObject.doProcess > > ends up with vt = VT_ERROR which is correct > >
- Next message: Alexander Nickolov: "Re: Destroy the parent of the control"
- Previous message: Alexander Nickolov: "Re: Global Method"
- In reply to: BigFish: "How to Pass a SafeArray of UDT's as VARIANT"
- Next in thread: Igor Tandetnik: "Re: How to Pass a SafeArray of UDT's as VARIANT"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|