bonsoir,
Je transforme une application VB6 en VB2005 : Ouf je m'accroche !
voici ma classe de base : rien de tres .....
Je cree ma classe de collection comme suite :
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 Public Class cArbHier Private mstrArbHierCode As String Private mstrArbHierDescription As String Public Property ArbHierCode() As String <div style="margin-left:40px">Get <div style="margin-left:40px">Return mstrArbHierCode</div>End Get Set(ByVal value As String) <div style="margin-left:40px">mstrArbHierCode = value</div>End Set</div>End Property Public Property ArbHierDescription() As String Get Return mstrArbHierDescription End Get Set(ByVal value As String) mstrArbHierDescription = value End Set End Property End Class
les lignes suivantes fonctionne correctement :
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 Imports System.Collections Public Class cArbHiers Private mCollection As System.Collections.Generic.List(Of cArbHier) Private mlinkArbHier As cArbHier Sub New() mCollection = New System.Collections.Generic.List(Of cArbHier) mlinkArbHier = New cArbHier End Sub Public Function Add(ByVal obAjouter As cArbHier, ByVal lngKey As Integer) As cArbHier mCollection.Add(obAjouter) Add = obAjouter End Function Public ReadOnly Property Item(ByVal Index As Integer) As cArbHier Get Item = mCollection.Item(Index) End Get End Property Public ReadOnly Property Count() As Integer Get Count = mCollection.Count End Get End Property Public Property cArbHier() As cArbHier Get If mlinkArbHier Is Nothing Then mlinkArbHier = New cArbHier End If cArbHier = mlinkArbHier End Get Set(ByVal value As Codex_Vp_App.cArbHier) mlinkArbHier = value End Set End Property End Class
Par Contre Celle-ci c'est la misére :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Dim toto As New cArbHier toto.ArbHierCode = "1Test" Dim coltoto As New cArbHiers coltoto.Add(toto) Console.WriteLine(coltoto.Item(1).ArbHierCode)
j'ai lu beaucoup mais je n'ai pas trouver de solution.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 For Each titi As cArbHier In coltoto Console.WriteLine(titi.ArbHierCode) Next
Merci de votre aide
Ps conseil l'excelent tutorial : http://plasserre.developpez.com
Partager