Bonjour
Je recherche la possibilité de stocker dans une collection 9 données par ajout
Pour le moment j'essaie une Hashtable en passant pas un Objet aillant les 9 données.
Cela marche. je vois les données mais j'arrive pas a trouver le moyen d'y accéder par le code.
Pour lire les données je fait:
La classe Items:
*********************************************************
Public Class Items
#Region "Champs privés"
Private _Nom As String
Private _Type As String
Private _Obj As String
Private _Ind As String
Private _Format As Double
Private _Unit As String
Private _Selection As Boolean
Private _SelectInter As Boolean
Private _SeuilInter As Double
#End Region
#Region "Constructeur"
Sub New()
_Nom = ""
_Type = ""
_Obj = ""
_Ind = ""
_Format = 0
_Unit = ""
_Selection = False
_SelectInter = False
_SeuilInter = 0
End Sub
#End Region
#Region "Propriétés publiques"
Property Nom() As String
Get
Return _Nom
End Get
Set(ByVal value As String)
_Nom = value
End Set
End Property
Property Type() As String
Get
Return _Type
End Get
Set(ByVal value As String)
_Type = value
End Set
End Property
Property Obj() As String
Get
Return _Obj
End Get
Set(ByVal value As String)
_Obj = value
End Set
End Property
Property Ind() As String
Get
Return _Ind
End Get
Set(ByVal value As String)
_Ind = value
End Set
End Property
Property Format() As Double
Get
Return _Format
End Get
Set(ByVal value As Double)
_Format = value
End Set
End Property
Property Unit() As String
Get
Return _Unit
End Get
Set(ByVal value As String)
_Unit = value
End Set
End Property
Property Selection() As Boolean
Get
Return _Selection
End Get
Set(ByVal value As Boolean)
_Selection = value
End Set
End Property
Property SelectInter() As Boolean
Get
Return _SelectInter
End Get
Set(ByVal value As Boolean)
_SelectInter = value
End Set
End Property
Property SeuilInter() As Double
Get
Return _SeuilInter
End Get
Set(ByVal value As Double)
_SeuilInter = value
End Set
End Property
#End Region
End Class
******************************************************************
Ensuite je rempli ma Hashtable
******************************************************************
Inherits Items
Dim Doc As XmlDocument
Dim ListXml As XmlNodeList
Public Function Load() As CollectionXML
Public Coll As Hashtable
Coll = New Hashtable()
'Dim Nom As String 'Type, Obj, Ind, Format, Unit, Selection, SelectInter, SeuilInter
Dim Typ As XmlNode
Dim Types As XmlNode
Dim Items As XmlNode
Doc = New Xml.XmlDocument
Doc.Load("f:\essaie1.xml")
ListXml = Doc.GetElementsByTagName("type")
For Each Typ In ListXml
If Typ.Attributes("version").Value = "ACM1000" Then
For Each Types In Typ
Dim C As Items
If Types.LocalName = "mesures" Then
For Each Items In Types
C = New Items()
C.Nom = Items.SelectSingleNode("Nom").InnerText
C.Type = "mesure"
C.Obj = Items.SelectSingleNode("Obj").InnerText
C.Ind = Items.SelectSingleNode("Ind").InnerText
C.Format = Items.SelectSingleNode("Format").InnerText
C.Unit = Items.SelectSingleNode("Unit").InnerText
C.Selection = Items.SelectSingleNode("Selection").InnerText
C.SelectInter = Items.SelectSingleNode("SelectInter").InnerText
C.SeuilInter = Items.SelectSingleNode("SeuilInter").InnerText
Coll.Add(C.Nom, C)
Next
End If
If Types.LocalName = "entrees" Then
For Each Items In Types
C = New Items()
C.Nom = Items.SelectSingleNode("Nom").InnerText
C.Type = "entree"
C.Obj = Items.SelectSingleNode("Obj").InnerText
C.Ind = Items.SelectSingleNode("Ind").InnerText
C.Selection = Items.SelectSingleNode("Selection").InnerText
C.SelectInter = Items.SelectSingleNode("SelectInter").InnerText
Coll.Add(C.Nom, C)
Next
End If
Next
End If
Next
End Function
*************************************************************************
Par contre j'arrive pas a ressortir les valeurs
par exemple afficher: le Obj du 1er Nom qui correspond a la key 0
Merci de votre aide
Technicien en électricité industriel. En cours de reconversion par un BTS IRIS 1er année.
Actuellement en stage dans mon entreprise en R&D.