Exercice Visual Basic : Tableau avec Windows Form

Ecrire le code VB qui permet de réaliser l'interface suivante:

ExerciceVB-id2129


 

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
Public Class Form1
    Dim article, couleur As String
    Dim t(8, 5) As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        t(1, 1) = 350.25
        t(2, 1) = 750.5
        t(3, 1) = 49.5
        t(5, 1) = 800
        t(6, 1) = 1200
        t(8, 1) = 350
        t(3, 2) = t(3, 1)
        t(6, 2) = t(6, 1)
        t(3, 3) = 55.5
        t(5, 3) = 355
        t(6, 3) = 1100
        t(3, 4) = t(3, 3)
        t(4, 3) = 49
        t(4, 4) = 52
        t(5, 4) = 700
        t(3, 5) = t(3, 3)
        t(7, 5) = 50
        t(1, 0) = "Chaise en teck"
        t(2, 0) = "Table en teck"
        t(3, 0) = "Chaise en Pvc"
        t(4, 0) = "Table en Pvc"
        t(5, 0) = "Chaise de bureau Prestige"
        t(6, 0) = "Table de bureau Prestige"
        t(7, 0) = "Tapis de souris"
        t(8, 0) = "Visual basic facile"
        t(0, 1) = "Rouge"
        t(0, 2) = "Vert"
        t(0, 3) = "Blanc"
        t(0, 4) = "Noir"
        t(0, 5) = "Gris"
    End Sub
 
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        article = ComboBox1.SelectedItem
        TextBox2.Text = ""
    End Sub
 
    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Dim i, j As Integer
        couleur = ComboBox2.SelectedItem
        For i = 1 To 8
            If article = t(i, 0) Then
                Exit For
            End If
        Next
        For j = 1 To 5
            If couleur = t(0, j) Then
                Exit For
            End If
        Next
        TextBox1.Text = article & " " & couleur
        If t(i, j)  0 Then
            TextBox2.Text = t(i, j)
        Else
            TextBox2.Text = "Cet article n'existe pas dans cette couleur !"
        End If
    End Sub
End Class