VB.Net TextBox Allow Only Alphabet

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

vb.net textbox allow only alphabet


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


Project Source Code:


Public Class TextBox_Only_Alphabet


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

        If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsLetter(e.KeyChar) AndAlso Not Char.IsWhiteSpace(e.KeyChar) Then

            e.Handled = True

        End If

    End Sub
End Class




OUTPUT:



textbox allow only characters using vbnet



Share this

Related Posts

Previous
Next Post »