vendredi 24 juillet 2015

VB.NET - IF statement to check if typed key is not present in label

As the question says, i want to make an IF statement to check if the pressed key is not present in any of the six labels that i have created. In the six labels, a letter is randomly produced and placed into each.

I have this line of code but it doesn't work as intended as correct key presses still execute the code beneath.

If (e.KeyChar <> lblletter1.Text And e.KeyChar <> lblletter2.Text And e.KeyChar <> lblletter3.Text And e.KeyChar <> lblletter4.Text And e.KeyChar <> lblletter5.Text And e.KeyChar <> lblletter6.Text) Then
            score -= 1
            lblscore.Text = score
            incorrect += 1
        End If

Hope it is not too confusing

Aucun commentaire:

Enregistrer un commentaire