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
| Public Sub RemplirListe(ByRef Ctrl As Control, ByRef Tableau As Variant)
Dim Indice As Integer, Indice1 As Integer, Indice2 As Integer
Dim iCol As Integer, i As Integer
If (TypeOf Ctrl Is ComboBox) Or (TypeOf Ctrl Is ListBox) Then
Ctrl.Clear
If IsArray(Tableau) Then
Indice1 = LBound(Tableau)
Indice2 = UBound(Tableau)
End If
Indice1 = LBound(Tableau)
Indice2 = UBound(Tableau)
For Indice = Indice1 To Indice2
Ctrl.AddItem "" & Tableau(Indice)
Ctrl.ItemData(Ctrl.NewIndex) = Indice
Next Indice
ElseIf (TypeOf Ctrl Is ListView) Then
Ctrl.ListItems.Clear
If IsArray(Tableau) Then
Indice1 = LBound(Tableau)
Indice2 = UBound(Tableau)
End If
Indice1 = LBound(Tableau)
Indice2 = UBound(Tableau)
For Indice = Indice1 To Indice2
With Ctrl.ListItems.Add
.Tag = Indice
If Not IsArray(Tableau(Indice)) Then
.Text = "" & Tableau(Indice)
Else
iCol = 0
For i = LBound(Tableau(Indice)) To UBound(Tableau(Indice))
If iCol = 0 Then
.Text = "" & Tableau(Indice)(i)
Else
.SubItems(iCol) = "" & Tableau(Indice)(i)
End If
iCol = iCol + 1
If iCol > Ctrl.ColumnHeaders.Count Then Exit For
Next i
End If
End With
Next Indice
End If
End Sub |
Partager