VB.Net TextBox Allow Only Numbers

How To Make A TextBox Accept Only Numeric Values Using Visual Basic.Net

textbox accept only digits characters in vb.net


In This VB.Net Tutorial we will See How To Make A TextBox That Allow Only Number Characters On KeyPress Event using Visual Basic.Net Programming Language And Visual Studio IDE .


Project Source Code:


Public Class TextBox_Only_Number


    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress

        If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) Then

            e.Handled = True

        End If

    End Sub
End Class




OUTPUT:



textbox allow only number using vbnet



Share this

Related Posts

Previous
Next Post »