Discussion Locked

ASCII key press function

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am not sure how to get this to work.
I want to as my splash screen is loading in a VB6 program(or any other form)
I want to do something like
If keypress xyz then
call load (form)
end if
I want a way to by pass my login. What I want is a way to gain access to my Admin form to reset passwords if the user screws up

Dennis

7 replies

by donq

The KeyPress Event applies to a Bound Object Control, Check Box Control, Combo Box Control, Command Button Control, Form, etc. so it looks as though you could place your code within the splash screens "Form".

CAUTION: If you are attempting to bypass a database login you may need to hard code a recognized user name and password into the active Workgroup your code snippet passes to the login.

by bill_h

The Form_KeyDown event is triggered whenever a key is pressed; this would allow you to select a certain sequence, such as Shift-F3, to gain access to the Admin form. Sample code follows:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF3 Then
If Shift = 1 Then
MsgBox "You pressed 'F3' and 'Shift'..."
Else
MsgBox "You pressed 'F3'..."
End If
End If
End Sub

The actual key sequence, of course, would be known only to a select few.

Search the docs for other key constants to best suit your needs.

Hope this helps...

by bill_h

Oops...forgot a key element. If your form has visible and enabled controls, the Form_KeyDown event will *not* fire unless you set the 'KeyPreview' property of the form to TRUE.

Normally, the KeyDown event can be received only by the control thathas the input focus. If a form contains visible and enabled controls, the form itself can never have focus. The KeyPreview property allows the form to recognize and react to a KeyDown event before the controls recognize the event.

by bill_h

One more thing...the KeyPress event is also available, but it is unable to detect the state of the SHIFT, CTRL and ALT keys (KeyDown and KeyUp events *can*), and the only *control* keys the KeyPress event will respond to are the ENTER, TAB and BACKSPACE keys. KeyDown and KeyUp are much more versatile, IMHO...

This discussion is closed to new replies.