Google Answers Logo
View Question
 
Q: Visual Basic programminq question ( No Answer,   2 Comments )
Question  
Subject: Visual Basic programminq question
Category: Computers > Programming
Asked by: michned-ga
List Price: $2.00
Posted: 01 Feb 2005 15:52 PST
Expires: 03 Mar 2005 15:52 PST
Question ID: 467232
For Visual Basic 5.0, how would I create code that lets me press the
F1 key to close the program I am writing. I would also like to add a
prompt for a password that the user would need to enter for the app to
close. So the sequence would be 1) press F1, 2) enter password, so
that 3) program closes.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Visual Basic programminq question
From: ob1murry-ga on 02 Feb 2005 07:17 PST
 
Im not sure if you can assign F1 as the key since it is a function
key, but if you can, use the menu editor to create a menu with a Quit
option and assing the F1 key as the shortcut key, if that doesnt work
you have to write your own sub-procedure to wait for a key to be
pressed and checks the hex value to see if it matches the hex value of
the F1 key. Then you could either create a second form(say X) with a
textbox, and show it(X.show) from within the Form_Unload event in the
program, or you could use an input box that is coded in the
Form_Unload event, then just use an if statement to see if the
password matches, if it does than End, if not then return.
Subject: Re: Visual Basic programminq question
From: max_-ga on 18 Feb 2005 12:02 PST
 
Or better you can use the Form_KeyDown(KeyCode As Integer..) event,
the F1 KeyCode is 112.
For the password you can create a second form and show it as modal, so
the user can't use the main window until he enters the right password.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy