Compartir a través de


VarParseNumFromStr (Compact 2013)

3/26/2014

This function parses a string and creates a type-independent description of the number it represents.

Syntax

HRESULT VarParseNumFromStr( 
  OLECHAR* strIn, 
  LCID lcid, 
  unsigned long dwFlags, 
  NUMPARSE* pnumprs, 
  unsigned char* rgbDig 
); 

Parameters

  • strIn
    [in] Input string to be converted to a number.
  • lcid
    [in] Locale identifier.
  • dwFlags
    [in] Enables the caller to control parsing, therefore defining the acceptable syntax of a number.

    If this field is set to zero, the input string must contain nothing but decimal digits.

    Setting each defined flag bit enables parsing of that syntactic feature.

    Standard Automation parsing (for example, as used by VarI2FromStr) has all flags set (NUMPRS_STD).

  • pnumprs
    [in] Parsed results.
  • rgbDig
    [out] Array filled in with the values for the digits in the range 0-7, 0-9, or 0-15, depending on whether the number is octal, decimal, or hexadecimal. All leading zeros are stripped off.

    For decimal numbers, trailing zeros are also stripped off, unless the number is zero, in which case a single zero digit is present.

Return Value

Returns the HRESULT values shown in the following table.

Value

Description

S_OK

Success.

E_OUTOFMEMORY

Internal memory allocation failed. (Used for DBCS only to create a copy with all wide characters mapped narrow.)

DISP_E_TYPEMISMATCH

There is no valid number in the string, or there is no closing parenthesis to match an opening one.

In the former case, cDig and cchUsed in the NUMPARSE structure will be zero.

In the latter, the NUMPARSE structure and digit array are fully updated, as if the closing parenthesis was present.

DISP_E_OVERFLOW

For hexadecimal and octal digits, there are more digits than will fit into the array.

For decimal, the exponent exceeds the maximum possible.

In both cases, the NUMPARSE structure and digit array are fully updated (for decimal, the cchUsed member excludes the entire exponent).

Remarks

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

Requirements

Header

oleauto.h

Library

oleaut32.lib

See Also

Reference

Automation Functions