怎么判断_variant_t的值是什么类型
1个回答
展开全部
/*将_variant_t 类型的变量,转换成字符串(比如如果是数字,则转换成数字对应的字符串 :如 10.2 -> "10.200000")*/_variant_t var;
CString str; //转换以后的字符串
if (var.vt == VT_I4){long lNum;char szCh[21];
str=var.bstrVal;
WideCharToMultiByte
(CP_ACP, 0, var.bstrVal, -1,
if( var.vt == VT_BOOL){BOOL bVar;lNum=var.lVal;
bVar= var.boolVar==0? FALSE : TRUE;}//以下代码演示为其余类型(补充)
switch(var.vt){case VT_BSTR: //var is BSTR type
str=var.bstrVal;break;case VT_I2: //var is short int type
str.Format("%d",(int)var.iVal);break;case VT_I4: //var is long int type
str.Format("%d",var.lVal);break;case VT_R4: //var is float type
str.Format("%10.6f",(double)var.fltVal);break;case VT_R8: //var is double type
str.Format("%10.6f",var.dblVal);break;case VT_CY: //var is CY type
str=COleCurrency(var).Format();break;case VT_DATE: //var is DATE type
str=COleDateTime(var).Format();break;case VT_BOOL: //var is VARIANT_BOOL
CString str; //转换以后的字符串
if (var.vt == VT_I4){long lNum;char szCh[21];
str=var.bstrVal;
WideCharToMultiByte
(CP_ACP, 0, var.bstrVal, -1,
if( var.vt == VT_BOOL){BOOL bVar;lNum=var.lVal;
bVar= var.boolVar==0? FALSE : TRUE;}//以下代码演示为其余类型(补充)
switch(var.vt){case VT_BSTR: //var is BSTR type
str=var.bstrVal;break;case VT_I2: //var is short int type
str.Format("%d",(int)var.iVal);break;case VT_I4: //var is long int type
str.Format("%d",var.lVal);break;case VT_R4: //var is float type
str.Format("%10.6f",(double)var.fltVal);break;case VT_R8: //var is double type
str.Format("%10.6f",var.dblVal);break;case VT_CY: //var is CY type
str=COleCurrency(var).Format();break;case VT_DATE: //var is DATE type
str=COleDateTime(var).Format();break;case VT_BOOL: //var is VARIANT_BOOL
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询