Thursday, September 18, 2008

Numeric Decimal TextBox – Made easy with VB.Net (2005&2008)

You just need to put this code in TextBox1 Leave event. Try this

Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave

Dim d As Decimal = Me.TextBox1.Text Me.TextBox1.Text = Decimal.Round(d, 2).ToString("f2")

End Sub

The "f2" formats a floating point number with 2 decimal points

0 comments:

Post a Comment