Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Visual Basic Key Down event only working once?

$
0
0

Hi,

For some reason or another the Key press event doesn't seem to be working properly and I can figure out why. (probably because I only started using VB today). 

Private Sub Btn_golemstart_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Btn_golemstart.KeyDown

        If e.KeyCode = Keys.F5 Then
            Timer_ancientgolem.Enabled = True
            My.Computer.Audio.Play(My.Resources.Electronic_Chime, AudioPlayMode.Background)
        End If

That's the code I'm using to start a timer counting down to zero from 300. Now the first time I press F5 it works. The tone plays and the timer starts. However once the timer reaches 0 and resets itself back to 300 the F5 key cannot be used to start it again.

This applies to the other timers except they don't even work in the first place, despite using the same code (only changes in names of buttons etc.)

Private Sub Btn_lizardstart_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Btn_lizardstart.KeyDown

        If e.KeyCode = Keys.F6 Then
            Timer_lizard.Enabled = True
            My.Computer.Audio.Play(My.Resources.Electronic_Chime, AudioPlayMode.Background)
        End If

I must be doing something wrong, could someone be kind and point out where the issue lies?

Thanks.


Viewing all articles
Browse latest Browse all 12583

Trending Articles