Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
I need to allow user to type only numbers for that i have the coding

VB
Private Sub AllowOnlyNumber(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

              If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
                      Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
            e.Handled = True
        End If
        If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
            e.Handled = False
        End If
        If (e.KeyChar = ".") Then
            e.Handled = False
        End If


    End Sub



It allows user to type only numbers and Point (.)
Is there any way to allow to type only 2 digit after Point (.)
can any1 help !!!!!!!!!
Posted

 
Share this answer
 
You can use numericupdown to do this!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900