Bonjour ,

J'ai fais ce exercice avec la saisie d'un tableaux de deux dimension mais le problème chaque fois à l'exécution du programme , il me donne la saisie du tableaux de deux dimension , c'est manuel , c'est possible de saisir les éléments du tableaux de deux dimension sur le code de programme pour une exécution automatique sans saisir le tableaux manuellement.


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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
 
Public Class Form1
 
    Dim tab(8, 5) As String
    Dim i, j As Integer
    Dim prix As String
 
    Function selection()
 
        Label4.Text = ComboBox1.Text & " " & ComboBox2.Text
 
        If ComboBox1.Text <> "" And ComboBox2.Text <> "" Then
 
            i = ComboBox1.SelectedIndex + 1
            j = ComboBox2.SelectedIndex + 1
 
 
            prix = tab(i, j)
 
            If prix <> "" Then
 
                Label5.Text = "cet article vaut " & prix & " DH "
 
            Else
 
                Label5.Text = " Cet article n'existe pas dans cette couleur !"
 
 
            End If
        End If
 
        Return 0
 
 
 
    End Function
 
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        '------------------------remplisser le tableaux 2D ------------------------'
 
        For i = 0 To 8
            For j = 0 To 5
 
 
                If i = 0 And j = 0 Then GoTo 1
 
                If i = 0 Then
 
 
                    tab(i, j) = InputBox("donnez la couleur de la coulone" & j)
 
 
                Else
 
                    If j = 0 Then
                        tab(i, j) = InputBox("donnez l'article de la ligne" & i)
 
                    Else
 
                        tab(i, j) = InputBox("donnez le prix de la case Tab(" & i & "," & j & ")")
 
                    End If
                End If
 
 
1:          Next
        Next
 
 
        '-------------remplisage des couleurs --------------------' 
 
        For i = 1 To 8
 
            ComboBox1.Items.Add(tab(i, 0))
 
            If i < 6 Then
 
                ComboBox2.Items.Add(tab(0, i))
 
 
            End If
 
        Next
 
 
    End Sub
 
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        selection()
 
    End Sub
 
    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
 
    End Sub
 
    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
 
    End Sub
 
    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        selection()
 
    End Sub
 
    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
 
    End Sub
End Class