Share via


IDataFunctions_4_0::ConvertStringToCurrency Method [C++]

Use this method to convert a string representation of a monetary value into a currency Variant, based on the specified locale and currency symbol.

Definition

[C++]

HRESULT IDataFunctions_4_0::ConvertStringToCurrency(VARIANTvtMoneyString,
 VARIANTvtLocale,
 VARIANTvtCurrencySymbol,
 VARIANT*pvtRet);

[Visual Basic]

Function ConvertStringToCurrency(vtMoneyString As Variant,
 Optional vtLocale As Variant,
 Optional vtCurrencySymbol As Variant) As Variant

Parameters

  • vtMoneyString[C++]
    [in] A VARIANT that contains the currency string to convert.
  • vtMoneyString[Visual Basic]
    A Variant that contains the currency string to convert.
  • vtLocale[C++]
    [in, optional] A VARIANT that contains the locale to be used when converting the string to a currency VARIANT. If this parameter is not specified, the value of the Locale property of the DataFunctions object is used.
  • vtLocale[Visual Basic]
    A Variant that specifies the locale to use when converting the string to a currency Variant. If this parameter is not specified, the value of the Locale property of the DataFunctions object is used.
  • vtCurrencySymbol[C++]
    [in, optional] A VARIANT that contains the currency symbol to expect when converting the currency string.
  • vtCurrencySymbol[Visual Basic]
    A Variant that contains the currency symbol to expect when converting the currency string.
  • pvtRet[C++]
    [out, retval] A pointer to a VARIANT used to return the string representation of the converted monetary value. This will be set to NULL if the monetary value string is not valid.

Return Values

[C++] The parameter pvtRet returns the parsed value or NULL if the input monetary value is not parsable. The method returns a failed HRESULT upon critical error, such as receiving an invalid argument.

[Visual Basic] If this method completes successfully, it returns a Variant used to return the string representation of the converted monetary value.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

[C++] The pvtRet parameter contains valid data only if the method completes successfully.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

[Visual Basic]

Example

<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim Result
Dim Amount
' vtAmount is a string representation of a monetary value 
Set MSCSDataFunctions = Server.CreateObject("Commerce.DataFunctions")
' Set to USA
myLocale = 1033
MSCSDataFunctions.Locale = myLocale
Result = MSCSDataFunctions.ConvertStringtoCurrency(vtAmount, _
    myLocale, "$")
Response.Write "USA: " & Result & "<P>"

%>
</BODY>
</HTML>

See Also

[C++]DataFunctions Object

[C++]IDataFunctions_4_0::get_Locale, put_Locale

[C++]IDataFunctions_4_0::LocalizeCurrency

[C++]IDataFunctions_4_0::ConvertMoneyStringToNumber

[Visual Basic]DataFunctions Object

[Visual Basic]DataFunctions.Locale

[Visual Basic]DataFunctions.LocalizeCurrency

[Visual Basic]DataFunctions.ConvertMoneyStringToNumber

Copyright © 2005 Microsoft Corporation.
All rights reserved.