I have a few questions about VARIANT structures that hopefully someone can fill me in on:

1. What is the exact size in memory for a variant structure. One source suggests 16 bytes, another 20 bytes...??

2. Im trying to piece together an array of doubles (X,Y,Z) coordinates. The API param requires a VARIANT in this place. From VBA work, i know its an array of doubles.. but i dont know anything more on how it set the VARIANT structure to point to the array.

3. How does VB know that the varaint array (whatever type) size. The function could assume 3 for x,y,z.. but In VB with a generic array, how does it know? There is no param in the Variant Structure for array size...

I've been piddling with the varriant business for two days and got nowhere at all... As well, i keep getting error codes back, but they mean squat to me with out a text translation ~ but i failed to find an Api to do so... C0000005 ? etc...

Has anyone debuged VB to follow how it operates when it comes to its varriant structures? Im at a complete standstil with this :rolleyes: . If anyone can shed some light (any thoughts at all) it would be very much appreciated... Thanx!

Here is what im doing so far:

align 4
center REAL8 10.4, 4.25, 0.0 ; x,y,z
radius REAL8 27.0
pICircle dd 0
Vvv VARIANT <VT_R8 or VT_ARRAY,0,0,0,<offset center>>

coinvoke pIModelSpace, IAcadBlock, AddCircle, Vvv, radius, addr pICircle

PrintHex eax
PrintHex pICircle

and here is the PROTO definition:

AddCircleProto typedef proto IAcadBlock_AddCircleProto :DWORD,:VARIANT,:REAL8,:DWORD

(pTHIS, CenterPoint, Radius, lpReturnedInterface)

Thanx a ton!
Posted on 2002-12-19 00:17:36 by NaN
I found this link.. but im yet to figure it out, or if this is the solution...


Posted on 2002-12-19 00:36:12 by NaN
VARIANT size is definitely 16 bytes

For arrays VB uses the SAFEARRAY structure
Posted on 2002-12-19 02:34:35 by japheth
Thanx again Japheth,

I will have to do some playing around tonight with SafeArray's... i didnt know they even existed untill last night when i came across the above link...

However, thanx for the confirmation (helps eliminate the guess work and focus in on actual problems)...

Posted on 2002-12-19 11:53:36 by NaN

That was my last hurdle... Turns out it was the SafeArray as you suggested.

I successfully wrote a MASM32 program to Read an Ole2 Storage file (Excel), extract coordinate info, open Autocad, and draw a circle in modelspace :grin: :tongue: :grin:

Now its time to do some *real* programming....

Thanx again japheth for your help..
Posted on 2002-12-19 18:15:20 by NaN