Bonjour,

Je veux lister les attributs d’une classe crée en vb .net

J’ai essayé cette procédure mais il n’arrive pas à accéder à ma classe pour m’affichedr les attribues. J’ai pas trouvé une solution sur le net

Je me suis basé aussi sur ce lien mais j’arrive pas à m’en sortir
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
Dim t As Type
        t = Type.GetType("article" & False, True)
 
        Dim res As Reflection.MemberInfo() = t.GetMembers
 
        Dim index As Integer
        For index = 0 To res.Length
            Dim nom As String = res(index).Name
            Dim type1 As Type = res(index).GetType
            Dim nom_type As String = type1.Name
 
        Next

Voici la classe crée :

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Public Class article
    Private _num As Integer
    Private _nom As String
    Private _px_achat As Double
    Private _px_vente As Double
 
    Property num()
        Get
            Return _num
        End Get
        Set(ByVal value)
            _num = value
        End Set
    End Property
    Property nom()
        Get
            Return _nom
        End Get
        Set(ByVal value)
            _nom = value
        End Set
    End Property
    Property px_achat()
        Get
            Return _px_achat
        End Get
        Set(ByVal value)
            _px_achat = value
        End Set
    End Property
    Property px_vente()
        Get
            Return _px_vente
        End Get
        Set(ByVal value)
            If value >= _px_achat Then
 
                _px_vente = value
 
            Else
                Try
 
                    Throw New Exception
                Catch
                    MsgBox("erreur")
                End Try
 
 
            End If
 
 
            _px_vente = value
        End Set
    End Property
    Sub New()
 
    End Sub
 
    Sub New(ByVal n As Integer, ByVal m As String, ByVal pxa As Double, ByVal pxv As Double)
 
        num = n
        nom = m
        px_achat = pxa
        px_vente = pxv
 
 
    End Sub
 
    Sub affiche_attr()
 
        Dim t As Type
        t = Type.GetType("article" & False, True)
 
        Dim res As Reflection.MemberInfo() = t.GetMembers
 
        Dim index As Integer
        For index = 0 To res.Length
            Dim nom As String = res(index).Name
            Dim type1 As Type = res(index).GetType
            Dim nom_type As String = type1.Name
 
        Next
 
 
    End Sub