 |
 |

10-13-2004, 04:31 AM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 67
|
|
I need to cancel/abort the Keydown event on a textbox
|
I need to evaluate the keycode the user has entered (this is the easy part) and then let the procedure either proceed OR concel the event so that the keypress doesn't end up in the textbox.
I seem to remember a 'cancel event' type command in Access Basic but can't find the equivelant in VB.
Failing that do you have any tips on input masks 'cause I don't seem to be able to make the MSMask control work (I get an error when I try to place a total into one of them).
Thank you for your time.
Stuey
|
|

10-13-2004, 12:14 PM
|
 |
Junior Contributor
|
|
Join Date: Sep 2004
Location: Seattle
Posts: 211
|
|
|
perhaps try setting the keycode to 0 which won't go into the textbox(?)
|
|

10-13-2004, 01:00 PM
|
 |
Contributor
|
|
Join Date: May 2004
Location: Ohio, USA
Posts: 771
|
|
|
Could you please explain a little more?
By masks, do you mean having *** in the textbox instead of abc?
Is the textbox only supposed to accept numbers, or a specific range of letters?
Without my crystal ball, I can only guess at what you are looking for.
|
__________________
Brandon
Once you embrace the idea that your customers deserve to die...
...it frees your mind to invent splendidly profitable products - Dogbert
|

10-13-2004, 02:59 PM
|
|
Retired Contributor
|
|
Join Date: Mar 2002
Posts: 1,829
|
|
Like quarque said...
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case w,x,y,z 'Where w,x,y,z are any Ascii numbers you do not want to be entered.
KeyAscii = 0
End Select
End Sub
Edit: Actually, better to use the KeyAscii numbers...
|
Last edited by Agent707; 10-13-2004 at 03:09 PM.
|

10-13-2004, 03:00 PM
|
|
Newcomer
|
|
Join Date: Oct 2004
Posts: 12
|
|
I think he is wanting some sort of authentication such as a password or seriel code, you could do it with a text box and a button, the code below is a simple password code that could technically be used for seriel codes also.
Code:
Private Sub cmdCode_Click()
If txtCode.Text = "code1" Or "code2" Or "code3" Then 'I think OR would work if you have multiple codes, not sure though, i am a tad of a nub
MsgBox "Correct Code", 8, "Message Box" 'If they put in one of the correct codes, it displays this
Form1.cmdStart.Enabled = True 'Do something, in my program I had it activate the start and stop button in form1
Form1.cmdStop.Enabled = True 'ditto
Else
MsgBox "Wrong Code", 8, "Message Box" 'Wrong code punk <.<
End If
Form4.Hide 'Hides the password/authentication form (mine being form4) after they put in a right or wrong code
End Sub
I'm probably wrong though, so ignore me..
|
__________________
"Faith; noun. Belief without evidence in what is told by one who speaks without knowledge, of things without parallel." --- Ambrose Bierce
Last edited by Halor; 10-13-2004 at 03:05 PM.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|