VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Prevents special characters from being entered into a textbox

by Jon Hickman (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 15th February 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Prevents special characters from being entered into a textbox

Rate Prevents special characters from being entered into a textbox




'Private Sub txtLastName_KeyPress(KeyAscii As Integer)
    'KeyAscii = Prevent_Special_Chars(KeyAscii)
'End Sub

'function can be adjusted to allow/disallow any values you want


Public Function Prevent_Special_Chars(KeyAscii As Integer) As Integer
'prevents a user from entering a special characters and numbers into a control from where the function is called
    If (KeyAscii >= 33 And KeyAscii <= 64) Or (KeyAscii >= 91 And KeyAscii <= 96) Or (KeyAscii >= 123 And KeyAscii <= 126) Then
        Prevent_Special_Chars = 0
    Else
        Prevent_Special_Chars = KeyAscii
    End If
End Function

Download this snippet    Add to My Saved Code

Prevents special characters from being entered into a textbox Comments

No comments have been posted about Prevents special characters from being entered into a textbox. Why not be the first to post a comment about Prevents special characters from being entered into a textbox.

Post your comment

Subject:
Message:
0/1000 characters