DotNet Academy of Rajesh Rolen

Solutions by Rajesh Rolen

allow decimal values in textbox in c#.net windows forms.

to make textbox to allow decimal values in textbox in c#.net windows forms.

private void txtRate_KeyPress(object sender, KeyPressEventArgs e){ if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar) && !(e.KeyChar.Equals('.')))
e.Handled =true;}


---------------------------VB.NET-------------------------------
Dim decexist As Boolean = False
If (CType(sender, TextBox).Text.IndexOf(".") > 0) And e.KeyChar.Equals("."c) Then
decexist = True
End If

If (Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not (e.KeyChar.Equals("."c))) Or decexist Then
e.Handled = True
End If

0 comments:

Post a Comment

About this blog

My Blog List

Advertise On This Site

Site Info

Advertise on this Site

To advertise on this site please mail on RajeshRolen@gmail.com

Information Source

About

Pages

Dot Net Academy

Advertis in This Area of Site

Powered by Blogger.

Followers

Search This Blog