转自:http://iamzxf.blog.sohu.com/157600930.html
(1)与字符串CString:
_variant_t temp;
CString str_wtdw;
str_wtdw=temp.bstrVal;
(2)与整数int:
_variant_t temp;
int value;
value=temp.iVal;
//有时根据不同的整数类型需要采用相关的操作,例如:
value=temp.intVal;
(3)与浮点数double
_variant_t temp;
double value;
value=temp.dblVal;
(4)与日期型函数的转换
_variant_t temp;
DATE dt;
COleDateTime odt;
CString outdate;
dt=temp.date;
odt=COleDateTime(dt);
outdate=odt.Format("%Y年%m月%d日");
//这种转换方式有些问题,如果月是6月,可能会出现06月的情况
year.Format("%d年",odt.GetYear());
month.Format("%d月",odt.GetMonth());
day.Format("%d日",odt.GetDay());
outdate=year+month+day;