Bonjour,
voilà j'ai fait un programme qui simule un tirage de Lotto XD
Avec un petit jeu en plus qui demande à l'utilisateur 6 nombres et qui est cencé ajouter 1 à une variable (lorsque le nombre entré correspond au nombre sorti (par le programme)) et l'affiche dans un label, voici le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
 
    End Sub
 
    Private Sub Btn_tir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_tir.Click
 
        Lbl1.Text = CStr(CInt((41 * Rnd() + 1)))
        Lbl2.Text = CStr(CInt((41 * Rnd() + 1)))
        Lbl3.Text = CStr(CInt((41 * Rnd() + 1)))
        Lbl4.Text = CStr(CInt((41 * Rnd() + 1)))
        Lbl5.Text = CStr(CInt((41 * Rnd() + 1)))
        Lbl6.Text = CStr(CInt((41 * Rnd() + 1)))
 
    End Sub
 
    Private Sub BtnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPlay.Click
        Dim number, numbers, tableau(5) As String
 
        Dim i, B As Short
        Dim numberwin As Integer = 0
 
 
        Lbl1.Text = CInt((41 * Rnd() + 1))
        Lbl2.Text = CInt((41 * Rnd() + 1))
        Lbl3.Text = CInt((41 * Rnd() + 1))
        Lbl4.Text = CInt((41 * Rnd() + 1))
        Lbl5.Text = CInt((41 * Rnd() + 1))
        Lbl6.Text = CInt((41 * Rnd() + 1))
 
        For i = 0 To 5
            numbers = InputBox("Rentrez vos nombre ici", "Jeu fictif loterie", number)
 
            tableau(i) = numbers
            Try
                If tableau(i) = Lbl1.Text Or Lbl2.Text Or Lbl3.Text Or Lbl4.Text _
                            Or Lbl5.Text Or Lbl6.Text Then
                    numberwin += 1
 
                Else
                    Lbl1.Text = Lbl2.Text
                    Lbl1.Text = Lbl3.Text
                    Lbl1.Text = Lbl4.Text
                    Lbl1.Text = Lbl5.Text
                    Lbl1.Text = Lbl6.Text
 
                    Lbl2.Text = Lbl3.Text
                    Lbl2.Text = Lbl4.Text
                    Lbl2.Text = Lbl5.Text
                    Lbl2.Text = Lbl6.Text
 
                    Lbl3.Text = Lbl4.Text
                    Lbl3.Text = Lbl5.Text
                    Lbl3.Text = Lbl6.Text
 
                    Lbl4.Text = Lbl5.Text
                    Lbl4.Text = Lbl6.Text
                    Lbl4.Text = Lbl2.Text
 
                    Lbl5.Text = Lbl6.Text
                End If
 
            Catch ex As Exception
                MsgBox(ex.ToString)
 
            End Try
        Next
 
 
        Label1.Text = CStr(numberwin)
 
    End Sub
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Randomize()
    End Sub
End Class
il y a plusieurs problèmes :
1) dans tous les cas (que j'ai testé) , la variable "numberwin" contenait le chiffre (6), à mon avis le problème viens de la comparaison entre les valeurs du tableau et les labels

2) Y a t'il moyen de diminuer le nombre de lignes de codes pour exprimer ceci?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
  Lbl1.Text = Lbl2.Text
                    Lbl1.Text = Lbl3.Text
                    Lbl1.Text = Lbl4.Text
                    Lbl1.Text = Lbl5.Text
                    Lbl1.Text = Lbl6.Text
 
                    Lbl2.Text = Lbl3.Text
                    Lbl2.Text = Lbl4.Text
                    Lbl2.Text = Lbl5.Text
                    Lbl2.Text = Lbl6.Text
 
                    Lbl3.Text = Lbl4.Text
                    Lbl3.Text = Lbl5.Text
                    Lbl3.Text = Lbl6.Text
 
                    Lbl4.Text = Lbl5.Text
                    Lbl4.Text = Lbl6.Text
                    Lbl4.Text = Lbl2.Text
 
                    Lbl5.Text = Lbl6.Text
Merci d'avance, toute réponse est la bienvenue
PS: si besoin, posez vos questions.