Currently I'm having an issue/Struggling to understand how to pull the information out of a Class Module. How I understand it is if a Class Module was an Excel sheet an instance would be a row and the public property would be the columns I have issued this problem before see link (Retrieving information from a Class module VB.Net) here is where i am with the code
In side my Class Module
Public Class tDCVillains
Public Property Gothem As Integer
Public Property metropolis as Integer
End Class
Inserting the Information into the Class Module
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
Retrieving information out of the Class Module
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
its the for each statement the code doesn't like but i cant figure out why?
It seems as if you want to loop the properties of the type tDCVillains
. You can use 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