BCX COM Interface

COM Type-Cast Conversions

If any of variable data type declaration suffixes is used, COM parser will automatically convert VARIANTS to and from that data type.

Samples:


 ' parser will pass string variable and automatically convert to BSTR 
 cdonts.from = D$


 ' Parser will pass Integer variable. 
 app.activeworkbook.cells(1,3).value =  A%  


 ' Parser will pass float variable. 
 app.activeworkbook.cells(1,3).value =  B!

If no type is specified, BCX COM parser will pass long as a default data type!

The BCX COM parser uses similar syntax for type-casting as the C language. The only difference is that all casts are always from and to the VARIANT data type and casting may occur to and from one of the constants defined in table below.


 ' Parser will convert Integer A% to double precision float.
 app.activeworkbook.cells(1,3).value = (VT_R8) A%   


 ' result of GetCom method will be converted to float.
 B! =(VT_R4) app.activeworkbook.cells(4,3).value 

List of available conversion definitions:

Valid casts(VT_...) C/C++ equivalent member
VT_NONE void void
VT_UI1 unsigned char bVal
VT_UI1REF unsigned char* by reference
VT_I2 SHORT iVal
VT_I2REF SHORT* by reference
VT_I4 long lVal
VT_I4REF long* by reference
VT_R4 float fltVal
VT_R4REF float* by reference
VT_R8 double dblVal
VT_R8REF double* by reference
VT_UI8 unsigned __int64 uhVal
VT_UI8REF unsigned __int64* by reference
VT_I1 char bVal
VT_I1REF char* by reference
VT_UI2 USHORT uiVal
VT_UI2REF USHORT* by reference
VT_UI4 ULONG ulVal
VT_UI4REF ULONG* by reference
VT_INT int lVal
VT_INTREF int* by reference
VT_UINT UINT ulVal
VT_UINTREF UINT* by reference
VT_CY CY cyVal
VT_CYREF CY* by reference
VT_DATE DATE date
VT_DATEREF DATE* by reference
VT_BSTR BSTR bstrVal
VT_BSTRREF BSTR* by reference
VT_DISPATCH IDispatch* pdispVal
VT_DISPATCHREF IDispatch** by reference
VT_ERROR SCODE scode
VT_ERRORREF SCODE* by reference
VT_BOOL VARIANT_BOOL boolVal
VT_BOOLREF VARIANT_BOOL by reference
VT_UNKNOWN IUnknown* punkVal
VT_UNKNOWNREF IUnknown** by reference
VT_VARIANTREF VARIANT* by reference
VT_ARRAY SAFEARRAY parray
VT_ARRAYREF SAFEARRAY* by reference
VT_DECIMAL DECIMAL decVal
VT_DECIMALREF DECIMAL* by reference

Related topics: Object data type definition | List of all COM Interface Functions