Dear Yang
 
I have used variants in the passed for a bit.  And as described, they are
not too difficult to use.
 
A VARIANT is a structure that is designed to hold a variety of variable
types.  This is why it is called VARIANT.
 
As the MSDN shows you, there are two members to this structure.  One of them
specifies the type of variable content you are holding in the variant.  This
is one of the predefined constant values as identified in the MSDN.
 
The second in a union (I think) all a load of variables.  There is one
variable for each type of value.
 
Imagine for a moment that the VARIANT can hold two types of variable value,
ValueTypeA and ValueTypeB.  When you pass your VARIANT object into a method,
if you don't set it up right, the method will get confused.  Imagine that
the method expects you to pass in a VARIANT to hold a value for ValueTypeB.
Then it would be something like:
 
VARIANT sVar;
 
sVar.Type = TYPE_VALUETYPEB;
 
method.GetValue(&sVar);
value = sVar.valueTypeB
 
Or to pass in:
 
VARIANT sVar;
 
sVar.Type = TYPE_VALUETYPEB;
sVar.valueTypeB = XXXX;
method.SetValue(&sVar);
 
That is as much as I can tell you.  It is not hard.  Just set the correct
type and use the relevant variable from the union in the structure to
get/set the value associated with that type.
 
I hope this helps.
 
Andrew
 
 

  _____  

From: [EMAIL PROTECTED] on behalf of wellstyang
Sent: Mon 14/11/2005 13:15
To: msvc list
Subject: Re: [msvc] I wanna get complete knowledge on VARIANT


Hi,
I have read the information at MSDN relative to VARIANT. But I found it's
not easy for me to get a complete view of it,especially the use of it. I
only can found the basic knowledge of it. What I want to know is how to use
VARIANT. For example how to change VARIANT to char or BYTE, or how to use it
to send and receive data from an ActiveX, or another things.
I not only want to get the interface of it from MSDN, but also want know how
do the relative functions and classes work and why. Because the knowledge in
MSDN can't give me what I want. So please help me to get completely research
on it and the relative functions and classes.
Thanks again for any help.
Yang.







z v  ?  n { I ?   ?  H 
126  <http://www.126.com/help/126fab.htm>    q  ? -- S    I  ?  ?      ? V ?




This message has been scanned for viruses by
<http://bluepages.wsatkins.co.uk/?4318150> MailControl



This email and any attached files are confidential and copyright protected. If 
you are not the addressee, any dissemination of this communication is strictly 
prohibited. Unless otherwise expressly agreed in writing, nothing stated in 
this communication shall be legally binding.

<<application/ms-tnef>>

_______________________________________________
msvc mailing list
msvc@beginthread.com
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for 
subscription changes, and list archive.

Reply via email to