DataFunctions.ConvertMoneyStringToNumber Method (PIA)
Use this method to convert a money string to a number, based on the default or specified locale.
Definition
[Visual Basic .NET]
Imports Microsoft.CommerceServer.Interop
…
Public Function ConvertMoneyStringToNumber(vtMoney As Object,
vtLocale As Object) As Object
[C#]
using Microsoft.CommerceServer.Interop;
…
public object ConvertMoneyStringToNumber(objectvtMoney,
objectvtLocale);
Parameters
[Visual Basic .NET]
- vtMoney
An Object that contains a string representation of the monetary value to convert. - vtLocale
An Object that specifies the locale to use to convert the string. If this parameter is not specified, the value of the Locale property of the DataFunctions object is used.
[C#]
- vtMoney
An object that contains a string representation of the monetary value to convert. - vtLocale
An object that specifies the locale to use to convert the string. If you want the value of the Locale property of the DataFunctions object to be used, pass Type.Missing for this parameter.
Return Values
[Visual Basic .NET] If this method completes successfully, it returns an integer Object that represents the value of the specified string in the base monetary unit of the specified locale; otherwise, Null is returned.
[C#] This method returns an object that contains the converted monetary value.
Exceptions
This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.
Remarks
The ConvertMoneyStringToNumber method returns the value in the base monetary unit for a given locale. Thus, given a value in dollars, ConvertMoneyStringToNumber returns the number of cents in the dollar value.
Additionally, ConvertMoneyStringToNumber does not round values. For example, if you pass this method "123.009" the method returns 12300, not 12301.
This method returns an object of type int, not an OLE currency type.
In some cases, this method returns null when converting a string representation of monetary value to the currency object type for Swedish and Portuguese (Portugal) locales. To avoid this problem, use the Replace method of the string class (i.e. myString.**Replace(**MoneyString, CurrencyDigitGroupingSymbol, "")) to remove the currency digit grouping symbol from the money string prior to calling the method ConvertMoneyStringToNumber.
Example
[Visual Basic .NET]
Dim Result As Object
Dim Amount As Object
Amount = "12000"
DataFunctions df = New DataFunctions()
' Set Locale to USA
Result = df.ConvertMoneyStringToNumber("34.095", 1033)
Response.Write("USA: " & Result & "<P>")
[C#]
No example available.
Requirements
Namespace: Microsoft.CommerceServer.Interop
Platforms: Windows 2000, Windows Server 2003
Assembly: mscsasphelplib (in mscsasphelplib.dll)
See Also
DataFunctions.ConvertFloatString
DataFunctions.ConvertNumberString
Copyright © 2005 Microsoft Corporation.
All rights reserved.