"C" format specifier issue

  • Thread starter Thread starter sougata12
  • Start date Start date
S

sougata12

Guest
Imports System.Globalization
Imports System.Threading

Module Module1

Sub Main()

Dim value As Double = 123456789.12345
Dim current As CultureInfo = CultureInfo.CurrentCulture
Console.WriteLine($"The current culture is {current}")
Console.WriteLine($"The value under the current culture is: {value.ToString("C")}")
Console.WriteLine("-------------------------------------------------")
Dim newCulture As New CultureInfo("fr-FR")
Thread.CurrentThread.CurrentCulture = newCulture
Console.WriteLine($"The current culture is {newCulture}")
Console.WriteLine($"The value under the current culture is: {value.ToString("C")}")
Console.ReadLine()
End Sub
End Module

Initially the current culture was set to English(India) see pics below. And the currency symbol was initially set to the new Indian rupee symbol (see below).

1304159.png


1304165.png

The problem is that neither the new Indian rupee symbol is getting displayed nor the Euro symbol is getting displayed when the culture is getting changed to "fr-FR". See output below:

1304168.png

Also if I redo the same exercise by changing the currency symbol for the current culture (en-IN) to "$" through the control panel and if instead of "fr-FR" the new culture is set to "en-US" it works fine. See screenshot below:

1304190.png

Also everything works fine if I try to use the new Indian rupee symbol and the Euro symbol in an excel sheet. So can someone point out why I am able to display the currency symbols in excel sheet but not when I am running a vb code? The screenshot for the excel sheet is found below:

1304196.png


In my last post I was suggested o use the following line:

Console.OutputEncoding = Encoding.Unicode

But not the currency symbol does not get displayed despite using this extra line of code


Sougata Ghosh

Continue reading...
 
Back
Top