从类模块VB.Net

时间:2015-12-10 17:11:30

标签: vb.net class

目前我试图在一个类中存储一堆整数/字符串,插入信息不是问题,但由于某种原因,我无法弄清楚如何检索信息

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

插入信息

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

检索信息

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

我需要做什么才能从类模块中获取信息?

1 个答案:

答案 0 :(得分:0)

您在调用HardwareCards时引用该类型,而不是初始化对象。请注意如何在GrabAccessInfo中将HardwareCards实例声明并初始化为变量Hardware。为了访问您分配给对象变量硬件的信息,您需要在RackSlotAccess中引用它。

Sub RackSlotAccess(hardware As HardwareCards)
    'Perform logic, evaluations on hardware. Example:
    Dim currentRackAmount = hardware.RackAmount
End Sub