Register to reply

Press Enter to initiate Event in Visual Basics

by JasonRox
Tags: basics, event, initiate, press, visual
Share this thread:
JasonRox
#1
Sep29-09, 04:35 PM
HW Helper
PF Gold
JasonRox's Avatar
P: 2,327
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!
Phys.Org News Partner Science news on Phys.org
Flapping baby birds give clues to origin of flight
Prions can trigger 'stuck' wine fermentations, researchers find
Socially-assistive robots help kids with autism learn by providing personalized prompts
DavidSnider
#2
Sep29-09, 04:45 PM
PF Gold
P: 469
Visual Basic .NET?
JasonRox
#3
Sep29-09, 04:46 PM
HW Helper
PF Gold
JasonRox's Avatar
P: 2,327
Quote Quote by DavidSnider View Post
Visual Basic .NET?
Yes! :)

Well, it's like VB Basics Express or something.

DavidSnider
#4
Sep29-09, 04:48 PM
PF Gold
P: 469
Press Enter to initiate Event in Visual Basics

http://msdn.microsoft.com/en-us/libr...ox_events.aspx

All controls have a list of events.

Use the textbox_KeyUp event and check:

if e.KeyCode = Keys.Enter then
DoSubmitButtonProcessing()
end if
JasonRox
#5
Sep29-09, 04:57 PM
HW Helper
PF Gold
JasonRox's Avatar
P: 2,327
Quote Quote by DavidSnider View Post
if e.KeyCode = Keys.Enter then

I get an underline for that code saying like... Keycode not in system.args or something
DavidSnider
#6
Sep29-09, 05:13 PM
PF Gold
P: 469
Quote Quote by JasonRox View Post
I get an underline for that code saying like... Keycode not in system.args or something
Does your code look like this?

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
TurtleMeister
#7
Sep29-09, 07:23 PM
TurtleMeister's Avatar
P: 755
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:

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
JasonRox
#8
Sep30-09, 07:19 PM
HW Helper
PF Gold
JasonRox's Avatar
P: 2,327
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.


Register to reply

Related Discussions
Question about visual basics Programming & Computer Science 2
Visual Basics programming help required Advanced Physics Homework 8
Help with Visual Basics please Programming & Computer Science 0
Stumped on Visual Studio / Visual Basic Programming & Computer Science 5