Is VariantChangeType() have problem with BSTR to VT_I4 conversion with even numbers and odd numbers
-
Hi Guys, I am trying to round the value of long value. But i have this value in data type Variant.BSTR. I can convert to this value by changing its data type from BSTR to VT_I4 through VariantChangeType(), in this conversion this value will be get rounded to nearst integer. Again i should convert this value from VT_I4 to BSTR by VariantChangeType(). This is working fine for ODD numbers but failing for EVEN numbers. if(FAILED(VariantChangeType(&vtValue,&vtValue,VARIANT_NOVALUEPROP,VT_I4))) { ASSERT(false); } if(FAILED(VariantChangeType(&vtValue,&vtValue,VARIANT_NOVALUEPROP,VT_BSTR))) { ASSERT(false); } Ex: if vt.BSTR = "5.5" after conversion to VT_I4 its value will be 6 But if vt.BSTR = "6.5" My expected value is 7 here but after conversion to VT_I4 its value will be 6 only.....any idea please...need to set anything while using this api...
-
Hi Guys, I am trying to round the value of long value. But i have this value in data type Variant.BSTR. I can convert to this value by changing its data type from BSTR to VT_I4 through VariantChangeType(), in this conversion this value will be get rounded to nearst integer. Again i should convert this value from VT_I4 to BSTR by VariantChangeType(). This is working fine for ODD numbers but failing for EVEN numbers. if(FAILED(VariantChangeType(&vtValue,&vtValue,VARIANT_NOVALUEPROP,VT_I4))) { ASSERT(false); } if(FAILED(VariantChangeType(&vtValue,&vtValue,VARIANT_NOVALUEPROP,VT_BSTR))) { ASSERT(false); } Ex: if vt.BSTR = "5.5" after conversion to VT_I4 its value will be 6 But if vt.BSTR = "6.5" My expected value is 7 here but after conversion to VT_I4 its value will be 6 only.....any idea please...need to set anything while using this api...
For me it is crashing when I am changing BSTR to VT_I4 with change type , can you please give me the solution if you found? My code looks like: varValue.ChangeType(VT_I4); //_variant_t varValue is BSTR where varValue is BSTR type and it is null, how can we change in this situation?