sebastian.
Member
- Joined
- Sep 20, 2009
- Messages
- 17
- Programming Experience
- 1-3
Hi everybody!
I'm new here and I'm not a native speaker, so please don't be to severe .
My XML source file:
The following code is working, but I want to modify it a bit (see below):
The following is part of a call of the function in another class:
But now I don't want to hand over the Me.DataGridView1, but rather want to have a proper return value of the function so I can write the following line in this part of the code, where I'm calling the function:
So I don't want to use the ByRef parameter.
What return value instead of Object do I have to use?
I think result is of this type:
System.Collections.Generic.IEnumerable(Of <anonymous Typ>)
Many thanks in advance!
Sebastian
I'm new here and I'm not a native speaker, so please don't be to severe .
My XML source file:
VB.NET:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<pricelist>
<item>
<item_no>123</item_no>
<item_description>
<description1>new item abc</description1>
<description2>has this properties</description2>
</item_description>
<item_group>group 1 blabla</item_group>
</item>
<item>
...
</pricelist>
The following code is working, but I want to modify it a bit (see below):
VB.NET:
Public Class XMLdb
' Fields
Dim XMLfile As XElement
' Constructor
Sub New(ByRef strXMLFilePath As String)
' create XDocument and load xml file
Me.XMLfile = XElement.Load(strXMLFilePath)
End Sub
'Methods
Public Function GetXMLData(ByRef grid As DataGridView) As Object
Dim result = From item In XMLfile.Elements("item") _
Where item.Element("item_group").Value Like "group 1 *" _
Select New With { _
.no = item.<item_no>.Value, _
.group = item.<item_group>.Value _
'...
}
grid.DataSource = result.ToList
Return result
End Function
End Class
The following is part of a call of the function in another class:
VB.NET:
Dim XMLdbFile As New XMLdb(ofdXML.FileName) 'I get the ofdXML.FileName from an "OpenFileDialog"
Dim xmlresult = XMLdbFile.GetXMLData(Me.DataGridView1)
But now I don't want to hand over the Me.DataGridView1, but rather want to have a proper return value of the function so I can write the following line in this part of the code, where I'm calling the function:
VB.NET:
Me.DataGridView1.DataSource = xmlresult.ToList
So I don't want to use the ByRef parameter.
What return value instead of Object do I have to use?
I think result is of this type:
System.Collections.Generic.IEnumerable(Of <anonymous Typ>)
Many thanks in advance!
Sebastian