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
| Private Sub CommandButton1_Click()
Dim I As Long
Dim Trouve As Boolean
If ListBox1.ListIndex = -1 Then Exit Sub
For I = 0 To ListBox2.ListCount - 1
If ListBox2.List(I, 0) = ListBox1.List(ListBox1.ListIndex) Then
ListBox2.List(I, 1) = CLng(ListBox2.List(I, 1)) + 1
ListBox1.List(ListBox1.ListIndex, 1) = CLng(ListBox1.List(ListBox1.ListIndex, 1)) - 1
Trouve = True
End If
Next
If Not Trouve Then
ListBox2.AddItem
ListBox2.List(ListBox2.ListCount - 1, 0) = ListBox1.List(ListBox1.ListIndex, 0)
ListBox2.List(ListBox2.ListCount - 1, 1) = 1
ListBox1.List(ListBox1.ListIndex, 1) = CLng(ListBox1.List(ListBox1.ListIndex, 1)) - 1
End If
End Sub
Private Sub UserForm_Initialize()
ListBox1.AddItem
ListBox1.List(0, 0) = "Coca"
ListBox1.List(0, 1) = 10
ListBox1.AddItem
ListBox1.List(1, 0) = "Fanta"
ListBox1.List(1, 1) = 10
End Sub |
Partager