|
-
April 8th, 1999, 01:14 PM
#1
VARIANT types
How does one set a double type to a VARIANT RT_8 type?
Thanks
-
April 9th, 1999, 01:24 PM
#2
Re: VARIANT types
Hi Jim
There are two ways of doing this:
1)Here is some code to demonstrate the usage of the VARIANT type.
//----
VARIANT v_Var;
double d = 1.6;
v_Var.vt = VT_R8;
v_Var.dblVal = d;
//----
2) You can also create a COleVariant object and pass the double in the constructor. The COleVariant will be accepted anywhere the VARIANT is called for.
Hope this works out for you )
Rick
P.S. Send me a line to tell me how it worked out.
-
April 9th, 1999, 01:24 PM
#3
Re: VARIANT types
Hi Jim
There are two ways of doing this:
1)Here is some code to demonstrate the usage of the VARIANT type.
//----
VARIANT v_Var;
double d = 1.6;
v_Var.vt = VT_R8;
v_Var.dblVal = d;
//----
2) You can also create a COleVariant object and pass the double in the constructor. The COleVariant will be accepted anywhere the VARIANT is called for.
Hope this works out for you )
Rick
P.S. Send me a line to tell me how it worked out.
-
April 9th, 1999, 11:31 PM
#4
Re: VARIANT types
Rick,
I've been stuck on a VARIANT problem for some time. I wonder if you could help shed some light.
I have a MS ActiveX control. One of its methods is declared as:
void SetOutput(const VARIANT& newValue);
I'm quite sure that the method accepts only the BSTR part of the VARIANT. The method behaves as expected when I pack it with a BSTR with 1 or more characters:
CString cstrTemp = "a";
varTemp.vt= VT_BSTR;
varTemp.bstrVal = cstrTemp.AllocSysString();
SetOutput(varTemp);
However, I wish to call the method with a NULL character (i.e. 0x00). The question is: How do I put a 0x00 in the VARIANT as a BSTR?
Thanks,
NB. the control is MSComm32.ocx
--
Stephen
-
April 10th, 1999, 04:12 PM
#5
Re: VARIANT types
COleVariant has these Constructors:
COleVariant( LPCTSTR lpszSrc );
COleVariant( LPCTSTR lpszSrc, VARTYPE vtSrc );
COleVariant( CString& strSrc );
I'm sure you could fill a CString or the LPCTSTR string to a Null character, and then use the VARIANT operator to pass it along as the parameter for your function. Im not able to test this out, but this may work:
TCHAR temp[1];
temp[0] = '\0';
CString temp2(temp);
COleVariant var(temp);
The last line of code will give you your variant. Then call your function:
FunctionCall((VARIANT)var);
Hope this helps, again I haven't tried this out, but it should work.
-
April 12th, 1999, 03:22 PM
#6
Re: VARIANT types
To pass an empty VARIANT try;
variant.vt = VT_NULL;
or
variant.vt = VT_EMPTY;
in the help there is somthing about put in VT_ERROR but I'm not to shure how that works.
Rick
-
April 12th, 1999, 03:22 PM
#7
Re: VARIANT types
To pass an empty VARIANT try;
variant.vt = VT_NULL;
or
variant.vt = VT_EMPTY;
in the help there is somthing about put in VT_ERROR but I'm not to shure how that works.
Rick
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|