I am trying to format the currencies in my app using thousands grouping and decimal separation.
I used the following class to do this:
Public Class Globalizations
Public Shared nfi As NumberFormatInfo = New CultureInfo("el-GR", False).NumberFormat
Public Shared dtfi As DateTimeFormatInfo = New CultureInfo("el-GR", False).DateTimeFormat
Then, in my form I used this code to format my number according to what I wanted it to look like:
Dim MyNum As Double = (Me.TextBox1.Text * Me.TextBox2.Text / 100)
Me.TextBox3.Text = MyNum.ToString("N", Globalizations.nfi)
My problem is that this formatted number cannot participate in mathematical functions with the . symbol inside it as the thousands grouping symbol, but rather I have to use this command to make it usable:
Replace(Replace(Me.TextBox3, ".", ""), ",", ".")
Is there any way to remove the formating without this double Replace command? Or maybe is there anything else I can do, to make the formatted number usable in mathematical functions, without it de-formatted?
Also, is there a way to assign the value to my control's text property and format it at the same time, without using the intermediate variable MyNum? I mean something like the following which I tried, but doesn't work:
Me.TextBox3.Text = (CDbl(Me.TextBox1.Text) + CDbl(Me.TextBox2.Text)).ToString("N", Globalizations.nfi)