VB .Net Validation - Only Allow Numeric TextBox

in this tutorial we will share about How to Only Allow Numeric TextBox in VB .Net

Please make design form1 like below picture :
 in TextBox3 and TextBox4 we will validate only allow numeric
Below the code :
Public Class Form1
    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True
    End Sub
    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True
    End Sub
End Class
Please run your project and You can click here to download Project above / source code

Subscribe to receive free email updates:

0 Response to "VB .Net Validation - Only Allow Numeric TextBox"

Post a Comment