Udostępnij za pośrednictwem


COleCurrency::ParseCurrency

Call this member function to parse a string to read a currency value.

BOOL ParseCurrency(
   LPCTSTR lpszCurrency,
   DWORD dwFlags = 0,
   LCID lcid = LANG_USER_DEFAULT 
);
throw(
   CMemoryException* 
);
throw(
   COleException* 
);

Parameters

  • lpszCurrency
    A pointer to the null-terminated string which is to be parsed.

  • dwFlags
    Indicates flags for locale settings, possibly the following flag:

    • LOCALE_NOUSEROVERRIDE   Use the system default locale settings, rather than custom user settings.
  • lcid
    Indicates locale ID to use for the conversion.

Return Value

Nonzero if the string was successfully converted to a currency value, otherwise 0.

Remarks

It uses national language specifications (locale IDs) for the meaning of nonnumeric characters in the source string.

For a discussion of locale ID values, see the section Supporting Multiple National Languages in the Windows SDK.

If the string was successfully converted to a currency value, the value of this COleCurrency object is set to that value and its status to valid.

If the string could not be converted to a currency value or if there was a numerical overflow, the status of this COleCurrency object is invalid.

If the string conversion failed due to memory allocation errors, this function throws a CMemoryException. In any other error state, this function throws a COleException.

Example

// works if default locale has dot decimal point
COleCurrency cur;
cur.ParseCurrency(_T("$135.95"), 0);
ASSERT(cur == COleCurrency(135, 9500));

Requirements

Header: afxdisp.h

See Also

Reference

COleCurrency Class

Hierarchy Chart

COleCurrency::Format

COleCurrency::GetStatus

Other Resources

COleCurrency Members