|
-
Sep 21st, 2007, 05:57 PM
#1
Thread Starter
New Member
[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?
Last edited by wisefire; Sep 21st, 2007 at 09:59 PM.
-
Sep 21st, 2007, 06:00 PM
#2
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
If a post has been helpful please rate it. 
If your question has been answered, pull down the tread tools and mark it as resolved.
-
Sep 21st, 2007, 06:08 PM
#3
Re: Preventing Keystrokes
You can see my post in this
with proper coding and easy to modify to suit your need.
-
Sep 21st, 2007, 06:11 PM
#4
Thread Starter
New Member
Re: Preventing Keystrokes
-
Sep 21st, 2007, 06:15 PM
#5
Re: Preventing Keystrokes
If this thread is resolved pull down your thread tools and mark it resolved.
If a post has been helpful please rate it. 
If your question has been answered, pull down the tread tools and mark it as resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|