Restricting field contents to Alphabetic characters only

  • 14 years ago

    Hello everyone,

    I'm working on a data-entry form and would like to restrict the data that I enter on certain fields to alphabetic characters only i.e. a -z, A - Z and Spaces.

    Is there any way I can acomplish this??

    Many thanks in advance.


  • 14 years ago


    I didn't touch my computer for a couple of months, but try this one...

    On keypress event of your textbox...

    Private Sub TextBox_KeyPress(KeyAscii As Integer)
        If KeyAscii < 65 Or KeyAscii > 129 Then        'for a - z and  A - Z only
            KeyAscii = 0
        End If
    End Sub

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou