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
| Option Explicit
Option Base 1
Sub test()
Dim dico As Scripting.dictionary
Dim test() As Integer
Dim i As Integer
Set dico = CreateObject("Scripting.Dictionary")
ReDim test(1, 2)
test(1, 1) = 1
test(1, 2) = 2
dico.Add "titi", test
ReDim test(1, 3)
test(1, 1) = 10
test(1, 2) = 20
test(1, 3) = 30
dico.Add "toto", test
dico("toto")(1, 3) = 40 'n'affecte pas la valeur mais ne renvoie pas de message d'erreur???
For i = 1 To UBound(dico("titi"), 2)
Debug.Print dico("titi")(1, i) 'affiche 1, 2
Next i
For i = 1 To UBound(dico("toto"), 2)
Debug.Print dico("toto")(1, i) 'affiche 10, 20 et 30 au lieu de 40?
Next i
End Sub |
Partager