VarNumFromParseNum

HRESULT VarNumFromParseNum( 
  [in]  NUMPARSE  *pnumprs,      
  [in]  unsigned char  *rgbDig,  
  [in]  unsigned long  dwVtBits,  
  [out]  VARIANT  *pvar          
);
 

Once the number is parsed, the caller can call VarNumFromParseNum to convert the parse results to a number. The NUMPARSE structure and digit array can be passed in unchanged from the VarParseNumFromStr call or you can fill in the parameters from any source. This function will choose the smallest type allowed that can hold the result value with as little precision loss as possible. The result variant is an [out] parameter, so its contents are not freed before storing the result.

Parameters

pnumprs
Parsed results. cDig = size of rgbDic
rgbDig
Contains the values of the digits. The cDig field of NUMPARSE contains the number of digits.
dwVtBits
Contains one bit set for each type that is acceptable as a return value (in many cases, just one bit).

VarNumFromParseNum flags that indicate acceptable result types:

VTBIT_I1 
VTBIT_UI1
VTBIT_I2
VTBIT_UI2
VTBIT_I4
VTBIT_UI4
VTBIT_R4
VTBIT_R8
VTBIT_CY
VTBIT_DECIMAL
pvar
Pointer to the result variant.

Return Value

The return value obtained from the returned HRESULT is one of the following.

Return value Meaning
S_OK Success.
E_OUTOFMEMORY Out of memory.
DISP_E_OVERFLOW The number is too large to be represented in an allowed type. There is no error if precision is lost in the conversion.

For rounding decimal numbers, the digit array must be at least one digit longer than the maximum required for data types. The maximum number of digits required for the DECIMAL data type is 29, so the digit array must have room for 30 digits. There must also be enough digits to accept the number in octal, if that parsing options is selected. (Hexadecimal and octal numbers are limited by VarNumFromParseNum to the magnitude of an unsigned long [32 bits], so they need 11 octal digits.)