Nikko
Nikko

Reputation: 385

Decimal Separator From Control Panel Customize Setting

I create an application with VB.NET

As instructed in MSDN I've changed Culture to en-US. It works to override decimal separator to dot if user sets regional format to whatever language with comma separator.

Public Sub New()

    Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
    Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-US")

    InitializeComponent()

End Sub

Now the problem is, how can I override decimal separator if user changed system's decimal separator from Control Panel > Region And Language > Additional Settings (in Format tab)?

CultureInfo is not able to override those custom settings. I need to override all the comma decimal separator to dot without using replace string function.

Upvotes: 3

Views: 546

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 156948

Set the NumberFormat property of the CultureInfo:

Dim myCI As New CultureInfo("en-US", False)
myCI.NumberFormat.CurrencyDecimalSeparator = "."

Thread.CurrentThread.CurrentCulture
   = Thread.CurrentThread.CurrentUICulture
   = myCI

Upvotes: 2

Related Questions