|
-
Jul 11th, 2000, 09:18 AM
#1
Thread Starter
Hyperactive Member
Ok I have it set that only numbers will work in the text box using the code
If keyascii < 48 or keyascii > 57 then
keyascii = 0
Beep
End if
That works fine, however I want them to be able to use the "Backspace", how can I do that while still having this code or a code that prevents All those keyascii's listed, except the backspace.
-RaY
VB .Net 2010 (Ultimate)
-
Jul 11th, 2000, 09:22 AM
#2
Try this.
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
'If the Key is not Backspace then
If Not KeyAscii = 8 Then
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Beep
End If
End If
End Sub
-
Jul 11th, 2000, 09:25 AM
#3
Thread Starter
Hyperactive Member
Nope
Thats what i thought, and had....but doesn't work for some reason...weird, huh?
-RaY
VB .Net 2010 (Ultimate)
-
Jul 11th, 2000, 09:31 AM
#4
Thread Starter
Hyperactive Member
how about this
If KeyAscii < 48 Or KeyAscii > 7 and keyascii < 9 then KeyAscii = 0
Beep
End If
what do you think about that megatron?
-RaY
VB .Net 2010 (Ultimate)
-
Jul 11th, 2000, 09:35 AM
#5
Strange..See if this works. I've changed 8 to vbKeyBack which is exactly the same except this is a consant.
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
'If the Key is not Backspace then
If Not KeyAscii = vbKeyBack Then
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Beep
End If
End If
End Sub
-
Jul 11th, 2000, 09:41 AM
#6
Thread Starter
Hyperactive Member
Weird
I don't get y that worked and the 8 didnt if it means the same...... Maybe I have code somewhere else defining 8, since im working a lot with numbers....Thanks!
-RaY
VB .Net 2010 (Ultimate)
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
|