Dim C As New List(Of Collection) Dim NewColl As New Collection NewColl.Add(MyObject) C.Add(NewColl)
For i = 1 To Number Port(i).add "ok" Next
For i = 1 To Number Port(i).add "ok" Next
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Function ChoisiMoi(Fo As Integer, Of As String) If Port(Fo).Count = 1 Then Port(Fo).Remove 1 Port(Fo).Add Of Else Port(Fo).Add Of End If End Function
J'aimerai créer plusieurs collections avec un index
J'ai 50 collections nommés de Port1 à Port50
.
Private Function ChoisiMoi(Fo As Integer, Offe As String) If Port(Fo).Count = 1 Then Port(Fo).Remove 1 Port(Fo).Add Offe Else Port(Fo).Add Offe End If End Function
Private Sub Form_Load() Dim fc As New Collection 'Final Collection (nb : attention à la portée) Dim tc As Collection 'Temp Collection Dim i As Integer, j As Integer For i = 1 To 5 Set tc = New Collection For j = 1 To 5 tc.Add "Ligne " & i & " : Colonne " & j Next j fc.Add tc Set tc = Nothing Next i 'item1 est une collection, on lit le 3e item MsgBox fc.Item(1).Item(3) 'item4 est une collection, on lit le 5e item MsgBox fc.Item(4).Item(5) End Sub