Hello friends, i have numbers below
5,2300 should be equal to 5.23
49.768,0000 should be equal to 49,768.00
2,0500 should be 2.05
anyone know how to solve this.
Thanks a lot in advance.
Hello friends, i have numbers below
5,2300 should be equal to 5.23
49.768,0000 should be equal to 49,768.00
2,0500 should be 2.05
anyone know how to solve this.
Thanks a lot in advance.
when working with numberformats we recommend to handle it via CultureInfo and and not with String Manipulations.
Double.Parse(YourVar, System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")).toString("N2")
inputNumbers As String() = {“5,2300”, “49.768,0000”, “2,0500”}
Use LINQ to process and convert the numbers
formattedNumbers As Double() = inputNumbers.Select(Function(num)
Double.Parse(num.Replace(“,”, “”).Replace(“.”, “”).Trim()) / 100).ToArray()
-Print the formatted numbers
For Each formattedNumber As Double In formattedNumbers
Console.WriteLine(formattedNumber.ToString(“0.00”))
Output:
5.23
49.77
2.05
Thank you so much @ppr .
Your solutions are just awesome!!!
if you also explain your code it will help a lot for the readers.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.