Showing posts with label VB .Net Tutorial. Show all posts
Showing posts with label VB .Net Tutorial. Show all posts

VB .Net Validation - Only Allow Numeric TextBox

2:54:00 AM 0
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