|
-
Dec 11th, 2005, 10:26 AM
#1
Thread Starter
New Member
[RESOLVED] KeyAscii problem
Hi all, Im very very new to this as you all can probably tell ! I am currently self learning for a hobby and I am referring to a book by Peter Wright called - Beggining Visual Basic 6. Anyow after a nice simple start I have come to an abrupt stop on hitting page 93 ! The problem is with code concerning a simple keypress command, the code I have is
Code:
Private Sub cmdOK_Click()
MsgBox "Input Accepted"
End Sub
Private Sub txtage_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") And KeyAscii > Asc("9") Then KeyAscii = 0
End Sub
Private Sub txtforname_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then KeyAscii = 0
End Sub
The code in itself seems self explanitory to me. it should have the effect of only allowing alphabetical numbers in txtforename, and numbers in in txtage by using conditions on the ascii code.
When in runtime the txtforename works A1 - only showing the alphabetical ascii characters while ascii code for the numbers are returned to 0 (is this what people refered to as nulled ?) But in the txtage it allows both text and numbers to be inputted and shown, when only numbers should be visable ? I have re-typed in the code a couple of times but still get the same results, can some one explain what is happening and wrong, thank you and TIA, please forgive my simpleness !
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
|