Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27156

problem with keydown event

$
0
0
In my project which is a tile scroller similar to a JRPG, the user presses the arrow keys to move his sprite, home to open his menu and F1 for help. All these work flawlessly, but for some reason, when i use this code for enter key, it only allows the event to occur once. all these events are nested in a single form1_keydown event. :
Code:

If e.KeyCode = Keys.Escape Then 'Close program if 'escape' key is pressed
            Application.Exit()
        ElseIf e.KeyCode = Keys.F1 Then
            Help.ShowDialog() 'show help form modally
        ElseIf e.KeyCode = Keys.Home Then
            gameMENU.ShowDialog() ' show menu form modally
        End If

If e.KeyCode = Keys.Enter Then
            If Pokemon_menu_.pokemonFirst.Text = "n/a" Then
                Me.btnOK.Enabled = True
                Me.btnOK.Visible = True
                Me.Dialogue.Visible = True
                Me.Dialogue.Text = "You can't leave yet! Trainers await you outside this village, you'll need a pokemon to defend yourself with first!"
            ElseIf Pokemon_menu_.pokemonFirst.Text <> "n/a" Then
                Me.btnOK.Enabled = True
                Me.btnOK.Visible = True
                Me.Dialogue.Visible = True
                Me.Dialogue.Text = "Hey! That's a Pokemon! Guess you're safe to adventure. Good luck!"
            End If
        End If


Viewing all articles
Browse latest Browse all 27156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>