次の方法で共有


VarNumFromParseNum (Compact 2013)

3/26/2014

This function converts the parsed number to a number of the VARIANT type.

Syntax

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

Parameters

  • pnumprs
    [in] Parsed results.

    The cDig member of this structure equals the size of rgbDig.

  • rgbDig
    [in] Contains the values of the digits.

    The cDig member of NUMPARSE contains the number of digits.

  • dwVtBits
    [in] Contains one bit set for each type that is acceptable as a return value (in many cases, just one bit).

    The following VarNumFromParseNum flags indicate acceptable result types:

    Flag

    Description

    VTBIT_I1

    Type can be CHAR.

    VTBIT_UI1

    Type can be unsigned char.

    VTBIT_I2

    Type can be short.

    VTBIT_UI2

    Type can be USHORT.

    VTBIT_I4

    Type can be long.

    VTBIT_UI4

    Type can be ULONG.

    VTBIT_R4

    Type can be float.

    VTBIT_R8

    Type can be double.

    VTBIT_CY

    Type can be CURRENCY.

    VTBIT_DECIMAL

    Type can be DECIMAL.

  • pvar
    [out] Pointer to the result variant.

Return Value

Returns the HRESULT values shown in the following table.

Value

Description

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.

Remarks

Passing invalid (and under some circumstances NULL) pointers to this function causes an unexpected termination of the application.

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 option 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.)

Requirements

Header

oleauto.h

Library

oleaut32.lib

See Also

Reference

Automation Functions
VARIANT and VARIANTARG