Dear Larry,
This does show the grouping if you include a standard currency format string
(That is what i showed in my sample in second TexBox2). But I want to set my
own format string (In TextBox1)
For example I wnat to my own format string like
Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.Leave
If Not IsNumeric(Me.TextBox1.Text) Then
Me.TextBox1.Text = "0"
End If
Me.TextBox1.Text = CDec(Me.TextBox1.Text).ToString("'Rs.'#,##0.00
CR;'Rs.'#,##0.00 DB;Zero")
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Me.MyCultureInfo.NumberFormat.CurrencyGroupSizes = New Integer() {3,
2}
Threading.Thread.CurrentThread.CurrentCulture = Me.MyCultureInfo
End Sub
Since I want to use the GroupingSizes (DigitGrouping) of the NumberFormat
in/with my custom format string as specified above, I have set my required
Currency Digit Grouping (CurrencyGroupSizes = New Integer() {3, 2}) and
passing in the parameter of the ToString() like this.
Me.TextBox1.Text = CDec(Me.TextBox1.Text).ToString("'Rs.'#,##0.00
CR;'Rs.'#,##0.00 DB;Zero", MyCultureInfo)
But the problem is it is not get used in the formatting of the above lline.
In short I want to specifiy a digit grouping (3,2) and it get it used in my
custom format string passed to Decimal's ToString().
Any Ideas?
Regards,
....Ashok
"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
"Rajesh Nandwani" <tr********@sancharnet.in> wrote
I am attaching sample. If you run the sample you will found 2
TextBoxes. The first one in which I am interested. The second one has a standard
currency string and shows the result correctly.
Try this:
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Me.MyCultureInfo.NumberFormat.CurrencyGroupSizes = New Integer()
{3, 2} Threading.Thread.CurrentThread.CurrentCulture = Me.MyCultureInfo
End Sub
Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.Leave
If Not IsNumeric(Me.TextBox1.Text) Then
Me.TextBox1.Text = "0"
End If
Me.TextBox1.Text = CDec(Me.TextBox1.Text).ToString("C")
End Sub