私は小さなプロジェクトに取り組んでいて、それをOOPに維持しようとしていくつかの問題に直面しました。
私はグローバル変数を持っています:
Public Stations As New Microsoft.VisualBasic.Collection()
そして2つのクラス: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
私はあなたがここで階層を見ることができると思います:
Collection Stations -> Object Station -> Collection Units -> Object Unit
XMLファイルからデータを取得し、それに応じて上記のコレクションにオブジェクトを追加するコードがあります。
しかし、コレクションに基づいてユニットのコレクションを取得する方法がわかりませんでしたStations
。私はこのようなことを試みました:
Dim st = Stations.Item("The key of a specific object in the Stations collection")
Dim stUnits = st.GetType().GetProperty("units")
stUnits
しかし、コレクションを取得しようとすると、次のようになります。
For Each unit In stUnits
それはstUnits
コレクションではないと言っています。私は少し混乱しています、可能な限りの助けに感謝します。