VarFormatNumber function (oleauto.h)

Formats a variant containing numbers into a string form.

Syntax

HRESULT VarFormatNumber(
  [in]  LPVARIANT pvarIn,
  [in]  int       iNumDig,
  [in]  int       iIncLead,
  [in]  int       iUseParens,
  [in]  int       iGroup,
  [in]  ULONG     dwFlags,
  [out] BSTR      *pbstrOut
);

Parameters

[in] pvarIn

The variant containing the value to format.

[in] iNumDig

The number of digits to pad to after the decimal point. Specify -1 to use the system default value.

[in] iIncLead

Specifies whether to include the leading digit on numbers.

Value Meaning
-2
Use the system default.
-1
Include the leading digit.
0
Do not include the leading digit.

[in] iUseParens

Specifies whether negative numbers should use parentheses.

Value Meaning
-2
Use the system default.
-1
Use parentheses.
0
Do not use parentheses.

[in] iGroup

Specifies whether thousands should be grouped. For example 10,000 versus 10000.

Note  Regular numbers and currencies have separate system defaults for all the above options.
 
Value Meaning
-2
Use the system default.
-1
Group thousands.
0
Do not group thousands.

[in] dwFlags

VAR_CALENDAR_HIJRI is the only flag that can be set.

[out] pbstrOut

Points to the formatted string that represents the variant.

Return value

This function can return one of these values.

Return code Description
S_OK
Success.
E_INVALIDARG
One or more of the arguments is not valid.

Remarks

This function uses the user's default locale while calling VarTokenizeFormatString and VarFormatFromTokens.

Requirements

Requirement Value
Target Platform Windows
Header oleauto.h
Library OleAut32.lib
DLL OleAut32.dll

See also

Formatting Routines

VarFormatFromTokens

VarTokenizeFormatString