I’m working on a small project and got into some troubles trying to keep it OOP.
I have a global variable:
Public Stations As New Microsoft.VisualBasic.Collection()
And 2 classess: Station & Unit:
Public Class Station
Property name As String
Property stype As String
Property units As New Collection
End Class
Public Class unit
Property name As String
Property lbl As String
Property ip As String
Property utype As String
End Class
I guess you can see the hierarchy in here:
Collection Stations -> Object Station -> Collection Units -> Object Unit
There’s a code which grab data from XML files and according to it adds objects to the collections above.
However , I didn’t figure how can I retrieve the collection of units based on the Stations collection.
I tried something like this:
Dim st = Stations.Item("The key of a specific object in the Stations collection")
Dim stUnits = st.GetType().GetProperty("units")
But when I’m trying to retrieve the stUnits collection:
For Each unit In stUnits
It says that stUnits isn’t a collection.
I am a bit confused, thanks for any help possible.
Silly me.
Forgot to set
stas a station object.And then , simply: