Bonjour,
J'ai créé un objet cPartition et un tableau contenant ces objets lorsque j'essaie de lire une propriété de mon objet j'obtiens une erreur:
erreur: "une variable de contôle for each sur les tableaux doit être de type variant"

si je change cPartition par variant j'obtiens une nouvelle erreur:
erreur "variable objet non defini"

Donc je n'arrive pas à lire une propriété de mon objet créé...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 Dim ctrl As cPartition
 For Each ctrl In TabObjetPartition() 
 If ctrl.NomPartition <> "" Then
 MsgBox "ok" & ctrl.NomPartition
 Else
 MsgBox "not ok"
 End If
 Next
 
 End Sub
Je vous remercie par avance de m'apporter une solution à ce problème qui tourne en rond.

Plus simplement comment lire une propriété d'un objet stocké dans un tableau.
J'ai aussi une autre question en rapport: Comment connaître le nom de l'objet dont on connaît la valeur de la propriété. Ce sont de objet créé dont voici l'exemple pour cPartition.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Public pNomPartition As String
Private pNomsVS() As New cVS
Public pNomVS As String
'Public AddVS()
 
'Public Property Get Numero() As String
'Numero = pNumeroPartition
'End Property
 
Public Property Get NomPartition() As String
NomPartition = pNomPartition
End Property
Public Property Let NomPartition(ValPartition As String)
pNomPartition = ValPartition
End Property
Public Property Get NomVS() As Variant
NomVS = pNomVS
End Property
Public Property Let NomVS(ValVS As Variant)
pNomVS = ValVS
End Property
 
Public Property Get NomsVS() As Variant
NomVS = pNomVS
End Property
Public Property Let NomsVS(TabVS As Variant)
pNomsVS = ValVS
End Property
 
Public Sub AddVS(ValVS As String)
ReDim pNomsVS(UBound(pNomsVS) + 1)
pNomsVS(UBound(pNomsVS)) = ValVS
End Sub