Home All Groups Group Topic Archive Search About
Author
23 Aug 2006 9:45 AM
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?

Author
23 Aug 2006 10:09 AM
Cor Ligthert [MVP]
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)


Show quoteHide quote
"Stuart Nathan" <stuart.nat***@homecall.co.uk> schreef in bericht
news:OdjfxjpxGHA.2168@TK2MSFTNGP06.phx.gbl...
>I know how to convert a number into a string containing the local currency,
> but does anyone know how to do the opposite?
>
Author
23 Aug 2006 2:23 PM
Stuart Nathan
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)
Author
23 Aug 2006 4:36 PM
Mythran
"Stuart Nathan" <stuart.nat***@homecall.co.uk> wrote in message
news:eKYx6%23rxGHA.356@TK2MSFTNGP02.phx.gbl...
> 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