Currency issue

  • Thread starter Thread starter Stuart Nathan
  • Start date Start date
S

Stuart Nathan

I know how to convert a number into a string containing the local currency,
but does anyone know how to do the opposite?
 
In fact it is not important, not any value holds the currency.

However the most that looks like it is.

dim a as decimal = Cdec(string)
 
Actually I wanted to convert £123,456.10 to 123456.1

I solved this by
r="£123,456.10"

r = r.Replace(CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, "") '
removes £
r = r.Replace(",", "") ' removes comma
Return Val(r)
 
Stuart Nathan said:
Actually I wanted to convert £123,456.10 to 123456.1

I solved this by
r="£123,456.10"

r = r.Replace(CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, "")
' removes £
r = r.Replace(",", "") ' removes comma
Return Val(r)

Dim inValue As String = "£123,456.10"
Dim outValue As Double
Dim result As Boolean

' Try to parse the inValue and store the actual numeric value in
' outValue.
result = Double.TryParse( _
inValue, _
NumberStyles.Currency, _
NumberFormatInfo.CurrentInfo, _
outValue _
)

If result
Console.WriteLine("The parsed value is " & outValue.ToString())
Else
Console.WriteLine("Could not parse the value.")
End If

HTH :)

Mythran
 
Back
Top