0

Currently I'm trying to store a bunch of integers/Strings in a Class inserting the information isn't a problem but for some reason i can't figure out how to retrieve the information

    Public Class HardwareCards
         Public Property RackAmount() As Integer
    End class 

Inserting the information

Sub GrabAccessInfo()
            Dim Hardware As New HardwareCards
            Dim HardwareCollection As New Collection
            Hardware.RackAmount = rst("RackAmount").Value
End Sub

Retrieving the information

Sub RackSlotAccess() 
    Dim type As Type = HardwareCards.GetType()
    Dim typename As Integer = type.FullName
    If HardwareCards.Hardware.DI32 >= 1 Then 'Inserting 32 bit Digital input card(s) 
        InsertDigAddresses(HardwareCards.Hardware.DI32, 32, "I", Slot, Rack)
    End If
End sub

What do i need to do to get the infomation out of the Class Module?

Alex Gale
  • 55
  • 1
  • 7
  • A) you created a local Hardware object in GrabAccessInfo, so it will disappear when that method ends (you info is lost). Same for the Collection. The Collection at least needs larger scope so when you store an object in it (you didnt) the data will not be lost. B) Do yourself a favor and do not use that awful VB Collection, use a `List(of T)` at least – Ňɏssa Pøngjǣrdenlarp Dec 10 '15 at 17:37

1 Answers1

0

You're referencing the type when calling HardwareCards, and not an initialized object. Notice how in GrabAccessInfo you declare and initialize an instance of HardwareCards into the variable Hardware. In order to access the information you assigned to the object variable Hardware, you would need to reference it in RackSlotAccess.

Sub RackSlotAccess(hardware As HardwareCards)
    'Perform logic, evaluations on hardware. Example:
    Dim currentRackAmount = hardware.RackAmount
End Sub
davidallyoung
  • 1,302
  • 11
  • 15
  • That worked thank you, but if the RackAmount is an array or in this case a collection how do you got though each one (i.e. RackAmount is the column and in that column i want to store each row) `For i = 1 to 50 Dim CurrentRackAmount = hardware.RackAmount(i) CurrentRackAmount = Do Something Next` – Alex Gale Dec 11 '15 at 08:50