Keydown et panel

Résolu
fabman21 Messages postés 22 Date d'inscription vendredi 29 avril 2011 Statut Membre Dernière intervention 13 septembre 2011 - 2 mai 2011 à 21:31
fabman21 Messages postés 22 Date d'inscription vendredi 29 avril 2011 Statut Membre Dernière intervention 13 septembre 2011 - 3 mai 2011 à 07:17
Bonsoir,J'ai une form avec un label j'aimerais qu'en appuyant sur la touche 'a' (par example) ce label se deplace vers le haut j'ai essayer avec un code comme ceci.mais cela ne marche pas (je fais mes debuts en programmation,soyez indulgent^_^)
Privat sub form1_keydown(double click sur levenement donc c'est automatique)
Me.panel1.location=newsystem.drawing.point(120,b) If e.value = 97 then b=b+1 end sub merci d'avance ( le .point me parait bizarre)

2 réponses

AlKatou Messages postés 95 Date d'inscription vendredi 7 février 2003 Statut Membre Dernière intervention 28 novembre 2017
3 mai 2011 à 01:25
salut,

avec ceci tu peux déplacer ton label dans chacune des directions à l'aide des touches fléchées bien sur.

à toi d'adapter à tes besoins si ça te convient

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

        ' pour la vitesse de déplacement
        Dim iCoefMove As Integer = 10

        ' recalcule la noouvelle position selon la touche appuyée
        ' iCoefMove * Abs(0 ou -1), -1 si la touche est appuyée
        Label1.Top Label1.Top - iCoefMove * System.Math.Abs(CInt(e.KeyValue Keys.Up))
        Label1.Top Label1.Top + iCoefMove * System.Math.Abs(CInt(e.KeyValue Keys.Down))
        Label1.Left Label1.Left - iCoefMove * System.Math.Abs(CInt(e.KeyValue Keys.Left))
        Label1.Left Label1.Left + iCoefMove * System.Math.Abs(CInt(e.KeyValue Keys.Right))
    End Sub




bonne continuation, alKa
3
fabman21 Messages postés 22 Date d'inscription vendredi 29 avril 2011 Statut Membre Dernière intervention 13 septembre 2011
3 mai 2011 à 07:17
Merci beaucoup
VIVE Visual Basic
0
Rejoignez-nous