Bonjour A Tous
Je débute en vba et je souhaiterais créer un objet contenant une propriété de type (liste ou collection ) d'un autre objet.
J'ai pour cela créer mon objet que j'appellerais ObjInfoGeneral contenant 3 propriétés ( Valider, légende, et paramètre) ou paramètre doit être une liste de mon second objet que j'appellerais ObjParametre
classe ObjInfoGeneral
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
34
35
36
37
38
39
40
41 Option Compare Database Option Explicit Private blnValider As Boolean Private strLegende As String Private objListeParam As Collection Property Get Valider() As String Valider = blnValider End Property Property Let Valider(Valider As String) blnValider = Valider End Property Property Get Legende() As String Legende = strLegende End Property Property Let Legende(Legende As String) strLegende = Legende End Property Property Get ListeParam(v As Integer) As ObjParametre ListeParam = objListeParams(v) End Property Property Set ListeParam(objValue As ObjParametre) Set objListeParam = objValue End Property 'Initialisation de l'objet Private Sub Class_Initialize() 'A la création de l'objet on initialise la propriété de validation a faux Me.Valider = False 'Initialisation de la collection de paramètre Set objListeParam = New Collection End Sub
classe ObjParametre
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 Option Compare Database Option Explicit Private strLabel As String Private strValeurDefaut As String Private strValeurReelle As String Private strControleValidation As String Private strReqControleValidation As String Property Get Label() As String Label = strLabel End Property Property Let Label(Label As String) strLabel = Label End Property Property Get ValeurDefaut() As String ValeurDefaut = strValeurDefaut End Property Property Let ValeurDefaut(ValeurDefaut As String) strValeurDefaut = ValeurDefaut End Property Property Get ValeurReelle() As String ValeurReelle = strValeurReelle End Property Property Let ValeurReelle(ValeurReelle As String) strValeurReelle = ValeurReelle End Property Property Get ControleValidation() As String ControleValidation = strControleValidation End Property Property Let ControleValidation(ControleValidation As String) strControleValidation = ControleValidation End Property Property Get ReqControleValidation() As String ReqControleValidation = strReqControleValidation End Property Property Let ReqControleValidation(ReqControleValidation As String) strReqControleValidation = ReqControleValidation End Property
Dans un formulaire j'instancie un objInfogeneral puis un ObjParametre mais au moment de faire objInfogeneral.objListeParams = ObjParametre erreur incompatibilité de type
y aurait il une personne pour m'aider s'il vous plait?
Merci et bonne année a tous
Partager