[Resolved] Preventing Keystrokes
Allright, Im programming a MMORPG, I dont want Numbers Nor Spaces in the Name. So, I set this up;
Code:
Private Sub txtName_KeyPress(KeyAscii As Integer)
Dim ch As String
ch = Chr$(KeyAscii)
If Not ( _
(ch >= "a" And ch <= "z") Or _
(ch >= "A" And ch <= "Z") _
) Then
' Cancel the character.
KeyAscii = 0
End If
End Sub
Works exactly how I wanted,But Wait, I can't backspace now. So, Does anyone know how I could make it allow the backspace key?
Re: Preventing Keystrokes
Here ya go.
Code:
Private Sub txtName_KeyPress(KeyAscii As Integer)
Dim ch As String
if not keyascii=vbkeyback then
ch = Chr$(KeyAscii)
If Not ( _
(ch >= "a" And ch <= "z") Or _
(ch >= "A" And ch <= "Z") _
) Then
' Cancel the character.
KeyAscii = 0
End If
End Sub
Re: Preventing Keystrokes
You can see my post in this
with proper coding and easy to modify to suit your need.
Re: Preventing Keystrokes
Re: Preventing Keystrokes
If this thread is resolved pull down your thread tools and mark it resolved.