|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Currency issueI 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) 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? > 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" <stuart.nat***@homecall.co.uk> wrote in message Dim inValue As String = "£123,456.10"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 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
VB Express SQL Express Remote Connection
Trouble with "Process's" please help! .NET equivilant of isnumeric copy HTML information Datagridview Search? How to open a text file only through my application but not others? Text missing from RadioButtons in Groupbox can I use Imports with a VB2005 class namespace? Implementing an interface? Printing in VB.Net |
|||||||||||||||||||||||