List de dictionary

List de dictionary - VB/VBA/VBS - Programmation

Marsh Posté le 05-09-2012 à 09:36:40    

Salut,
 
j'ai pour objectif de créer un script qui lira un fichier texte organisé de la sort :

category bleu
    echarpe
    capuche
end
 
category orange
    tshirt
    short
    pantalon
end
 


Le nombre de category est inconnue
et je voudrais pouvoir traiter cela avec une Liste de dictionary pour chaque caterory.
 
il y a moyen ?
Il est possible de creer un dictionary de dictionary ?
utiliser un tableau de dictionary ?
 
Merci


---------------
#mais-chut
Reply

Marsh Posté le 05-09-2012 à 09:36:40   

Reply

Marsh Posté le 05-09-2012 à 19:08:32    

En VBA rapidement  
 
 Dim Dict1 As Dictionary
    Dim Dict2 As Dictionary
 
    ' Create a dictionary instance.
    Set Dict1 = New Dictionary
    Set Dict2 = New Dictionary
 
    With Dict1
      .CompareMode = BinaryCompare
      .Add 1, "un"
    End With
     
    With Dict2
      .CompareMode = BinaryCompare
      .Add 1, Dict1
    End With
     
    Dim Dict3 As Dictionary
    Set Dict3 = Dict2.Item(1)
 
 
Comme dit mon boss "en informatique tout est possible"
 
sinon ton script a l'air assez simple  
une boucle qui parcourt les lignes du fichier  
si dans la ligne ya category alors tu fais un nouveau Dictionary  
si dans la ligne ya end et ben tu l'ajoutes dans ton Dictionary de Dictionary ou dans ton tableau suivant la methode choisie  
et sinon ben tu fais du add


Message édité par boomy29 le 05-09-2012 à 21:11:21
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed