Initialisation d'un objet dans un objet

kershin Messages postés 8 Date d'inscription samedi 8 mars 2003 Statut Membre Dernière intervention 10 novembre 2004 - 7 avril 2004 à 15:30
kershin Messages postés 8 Date d'inscription samedi 8 mars 2003 Statut Membre Dernière intervention 10 novembre 2004 - 7 avril 2004 à 16:26
Bonjour à tous,

J'ai du pour des raisons professionnelles me mettre au VB depuis une petite semaine. Jusqu'ici tout allait bien, mais je suis confronté ici à une petite énigme que je n'arrive pas à résoudre.

Pour résumer, j'ai 3 classes: list, folder et auction. List contient un tableau de folder, et chaque folder contient un tableau d'auction. Je récupère toutes les données à partir d'un fichier xml.

le problème que je rencontre est que je parviens sans problème à faire ceci:


dim bytIndexFolder as byte
bytIndexFolder = 1
For Each oNode In oNodeList
    Set oaFolders(bytIndexFolder) = New Folder
    bytIndexFolder = bytIndexFolder + 1
Next


Par contre, l'initialisation de l'objet suivant (auction) dans l'arborescence pose problème en raison je pense du property de la classe Folder. Ceci ne fonctionne donc pas:

    dim intIndexAuction as integer
    intIndexAuction = 1
    For Each oSubNode In oSubNodeList
      Set oaFolders(bytIndexFolder).Auctions(intIndexAuction) = New Auction
    Next


voici la composition de ma classe Folder:

Option Explicit

Private bytIdFolder As Byte
Private strNom As String
Private strDescription As String
Private oaAuctions() As Auction

Public Sub ResizeAuctionsArray(ByVal Index As Integer)
  ReDim oaAuctions(Index)
End Sub

Public Property Get Nom() As String
  Nom = strNom
End Property

Public Property Let Nom(ByVal NewValue As String)
  strNom = NewValue
End Property

Public Property Get Description() As String
  Description = strDescription
End Property

Public Property Let Description(ByVal NewValue As String)
  strDescription = NewValue
End Property

Public Property Get Auctions(ByVal Index As Integer) As Object
  Auctions = oaAuctions(Index)
End Property

Public Property Get IdFolder() As Byte
  IdFolder = bytIdFolder
End Property

Public Property Let IdFolder(ByVal NewValue As Byte)
  bytIdFolder = NewValue
End Property


Plz help %-6

3 réponses

kershin Messages postés 8 Date d'inscription samedi 8 mars 2003 Statut Membre Dernière intervention 10 novembre 2004
7 avril 2004 à 15:31
Je précise que c'est du VB6 bien entendu ;)
0
crenaud76 Messages postés 4172 Date d'inscription mercredi 30 juillet 2003 Statut Membre Dernière intervention 9 juin 2006 28
7 avril 2004 à 15:51
Il te faut une "Public Property Set Auctions" ...
sinon
Set oaFolders(bytIndexFolder).Auctions(intIndexAuction) = New Auction
ne peut pas fonctionner !!!

Christophe R.
0
kershin Messages postés 8 Date d'inscription samedi 8 mars 2003 Statut Membre Dernière intervention 10 novembre 2004
7 avril 2004 à 16:26
Merci, tu pourrais me donner un exemple ? car j'ai vraiment du mal pour saisir la manipulation de property set.

Si quelqu'un a un lien vers un tuto bien fait également, je suis preneur ;)
0
Rejoignez-nous