Press Enter to initiate Event in Visual Basics

In summary, the game is easier to play now because you can't have to click and type. The code to keep the Enter keystroke from sounding is included.
  • #1
JasonRox
Homework Helper
Gold Member
2,386
4
Ok so I'm trying to make this game I made easier to play because rightnow it's a pain.

Here's how the game playing goes now..

Click "Button"... Get Word In Textbox
Type in an Answer
Click "Button" to see if right and new word comes up


So the typing to click and typing and clicking is just a pain in the butt. Because to complete the game, you need to get 130 questions right. The game finishes fast but would be faster if the darn clicking wasn't need and I can just press "Enter" to activate the "Button".

THANKS!



The next question is that I want the little typing thing that "flashes" to STAY in the typing box.

Thanks!
 
Technology news on Phys.org
  • #2
Visual Basic .NET?
 
  • #3
DavidSnider said:
Visual Basic .NET?

Yes! :)

Well, it's like VB Basics Express or something.
 
  • #5
DavidSnider said:
if e.KeyCode = Keys.Enter then


I get an underline for that code saying like... Keycode not in system.args or something
 
  • #6
JasonRox said:
I get an underline for that code saying like... Keycode not in system.args or something

Does your code look like this?

Code:
Private Sub textBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyUp
    If e.KeyCode = Keys.Enter Then
...
    End If
End Sub
 
Last edited:
  • #7
The first thing you need to do is make your form capable of catching key strokes: Me.KeyPreview = True (you can put this in your form load event)

Next you need to add a sub to handle the KeyDown event. In the IDE click on your textbox then look at the properties window and click on the Events icon (it looks like a lightning bolt). You should see one named "KeyDown". Double click it and it will create the sub for you.

Next you need to add your code to the sub to handle the event. Since you want to handle the Enter key stroke it might look something like this:

Code:
If e.KeyCode = Keys.Enter Then
        'pur your code here to handle the event.
Endif

If you have sound schemes enabled on your OS then your next question may be: How do I get rid of the ding sound when I press the Enter key? It can be annoying. :)

Include this with your code to stop the ding: e.SuppressKeyPress = True
 
Last edited:
  • #8
Thanks HUGE guys!

I got it working! So much MORE convenient to play now.

I will publish soon. It's a language game that helps you grow your vocabulary.
 

1. What is the purpose of "Press Enter to initiate Event" in Visual Basics?

The purpose of "Press Enter to initiate Event" in Visual Basics is to allow a user to initiate a specific action or event by pressing the "Enter" key on their keyboard. This can be useful for creating user-friendly and efficient interfaces, as it eliminates the need for users to click on a specific button or icon.

2. How do I implement "Press Enter to initiate Event" in my Visual Basics program?

To implement "Press Enter to initiate Event" in a Visual Basics program, you can use the "KeyPress" event and check for the "Enter" key. You can then add the desired code or action to be executed when the "Enter" key is pressed.

3. Can "Press Enter to initiate Event" be used for multiple events in a Visual Basics program?

Yes, "Press Enter to initiate Event" can be used for multiple events in a Visual Basics program. You can assign different actions or codes to be executed when the "Enter" key is pressed in different parts of your program, allowing for more flexibility and functionality.

4. Is it possible to change the key for "Press Enter to initiate Event" in Visual Basics?

Yes, it is possible to change the key for "Press Enter to initiate Event" in Visual Basics. You can use the "KeyDown" or "KeyUp" events to check for different keys and execute the desired action accordingly.

5. Can "Press Enter to initiate Event" be used in web-based Visual Basics programs?

No, "Press Enter to initiate Event" cannot be used in web-based Visual Basics programs. This feature is specific to the desktop version of Visual Basics and is not supported by web browsers.

Similar threads

  • Programming and Computer Science
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
10
Views
981
Replies
7
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Programming and Computer Science
Replies
15
Views
6K
  • General Discussion
Replies
1
Views
1K
  • General Discussion
Replies
1
Views
1K
  • Programming and Computer Science
Replies
12
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Electrical Engineering
Replies
1
Views
2K
Back
Top