从 VB.Net 中的 Class 模块集合中检索信息
Retrieving information out of a Class module collection in VB.Net
目前我正在使用 issue/Struggling 来了解如何从 Class 模块中提取信息。
我的理解是,如果 Class 模块是 Excel sheet 一个实例将是一行,而 public 属性 将是我发布的列在看到 link () 之前这个问题是我使用代码
的地方
在我的 Class 模块旁边
Public Class tDCVillains
Public Property Gothem As Integer
Public Property metropolis as Integer
End Class
将信息插入 Class 模块
Sub GrabAccessInfo()
Dim DCVillains As New tDCVillains
Dim VillainsCollection As New Collection
DCVillains.Gothem = rst("Gothem").Value
DCVillains.metropolis = rst("metropolis").Value
VillainsCollection.Add(DCVillains)
rst.MoveNext()
End Sub
正在从 Class 模块中检索信息
Sub RackSlotAccess(DCVillains As tDCVillains)
For Each tDCVillains As System.Reflection.PropertyInfo In tDCVillains ' its not liking tDCVillains
Dim ObjGothem = DCVillains.Gothem
Dim Objmetropolis = DCVillains.metropolis
If ObjGothem >= 1 Then
InsertGothemVillains(ObjGothem, 32, "I", Slot, Rack)
End If
If Objmetropolis >= 1 Then
InsertmetropolisVillains(Objmetropolis, 16, "I", Slot, Rack)
End If
Next
End Sub
这是代码不喜欢的每个语句,但我不知道为什么?
看来你想循环tDCVillains
类型的属性。您可以使用 Type.GetProperties
:
Sub RackSlotAccess(DCVillains As tDCVillains)
Dim type = GetType(tDCVillains)
For Each tDCVillains As System.Reflection.PropertyInfo In type.GetProperties()
Dim ObjGothem = DCVillains.Gothem
Dim Objmetropolis = DCVillains.metropolis
If ObjGothem >= 1 Then
InsertGothemVillains(ObjGothem, 32, "I", Slot, Rack)
End If
If Objmetropolis >= 1 Then
InsertmetropolisVillains(Objmetropolis, 16, "I", Slot, Rack)
End If
Next
End Sub
目前我正在使用 issue/Struggling 来了解如何从 Class 模块中提取信息。
我的理解是,如果 Class 模块是 Excel sheet 一个实例将是一行,而 public 属性 将是我发布的列在看到 link (
在我的 Class 模块旁边
Public Class tDCVillains
Public Property Gothem As Integer
Public Property metropolis as Integer
End Class
将信息插入 Class 模块
Sub GrabAccessInfo()
Dim DCVillains As New tDCVillains
Dim VillainsCollection As New Collection
DCVillains.Gothem = rst("Gothem").Value
DCVillains.metropolis = rst("metropolis").Value
VillainsCollection.Add(DCVillains)
rst.MoveNext()
End Sub
正在从 Class 模块中检索信息
Sub RackSlotAccess(DCVillains As tDCVillains)
For Each tDCVillains As System.Reflection.PropertyInfo In tDCVillains ' its not liking tDCVillains
Dim ObjGothem = DCVillains.Gothem
Dim Objmetropolis = DCVillains.metropolis
If ObjGothem >= 1 Then
InsertGothemVillains(ObjGothem, 32, "I", Slot, Rack)
End If
If Objmetropolis >= 1 Then
InsertmetropolisVillains(Objmetropolis, 16, "I", Slot, Rack)
End If
Next
End Sub
这是代码不喜欢的每个语句,但我不知道为什么?
看来你想循环tDCVillains
类型的属性。您可以使用 Type.GetProperties
:
Sub RackSlotAccess(DCVillains As tDCVillains)
Dim type = GetType(tDCVillains)
For Each tDCVillains As System.Reflection.PropertyInfo In type.GetProperties()
Dim ObjGothem = DCVillains.Gothem
Dim Objmetropolis = DCVillains.metropolis
If ObjGothem >= 1 Then
InsertGothemVillains(ObjGothem, 32, "I", Slot, Rack)
End If
If Objmetropolis >= 1 Then
InsertmetropolisVillains(Objmetropolis, 16, "I", Slot, Rack)
End If
Next
End Sub