Each time a user presses a key on the keyboard, the "KeyDown" and "KeyUp" events trigger in a VB.NET application. You can use these events to disable and enable a form button. Coding for this event means the button's active state will toggle each time a user presses a key.
- Skill level:
Other People Are Reading
Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET," then click "Visual Studio" to open the VB.NET programming software.
Double-click the project file name in the list of recent projects to load the code. After the code pages load, right-click the form you want to use to monitor keyboard activity. Click "View Code" to open the form's code file.
Scroll down to the line of code labelled "Public Event KeyUp As KeyEventHandler." This code starts the function. You will place your button code after this line of code.
Type the following command to disable the button:
button1.Enabled = False
Activating this code "grays out" the button, so it is not active but visible for the user.
Type the following code to enable the button:
button1.Enabled = True
The code above returns the button to its active, clickable state.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for