Blood-HaZaRd
Blood-HaZaRd

Reputation: 2128

Convert To Decimal an arabic number

I have a numeric entry Nbr containing arabic numbers ١٢٣٤٥٦

My Issue is when I try to use the Convert.ToDecimal(Nbr)I receive a notification saying that the input format is wrong (not supported).

Is there any solution that I may use to bypass this problem without converting the Nbr from arabic to standard numbers (12345)

Thank you.

Upvotes: 2

Views: 689

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460208

I don't know if there is a better approach but following works. Convert the arabic numbers with Char.GetNumericValue to a roman number:

Dim arabicNumber = "١٢٣٤٥٦"
Dim romanNumber = From c In arabicNumber Select Char.GetNumericValue(c)
Dim number = string.Concat(romanNumber)

Now you can use Decimal.Parse:

Dim d As Decimal = Decimal.Parse(number)

The result with your string ١٢٣٤٥٦ is 123456.

Upvotes: 3

Related Questions