问题描述
目前我试图存储一堆整数/字符串在类中插入信息不是一个问题,但由于某种原因,我不能弄清楚如何检索信息
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
插入信息
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
我需要做什么来获取类模块中的信息?
What do i need to do to get the infomation out of the Class Module?
推荐答案
在调用HardwareCards时引用类型,而不是初始化对象。注意在GrabAccessInfo中如何声明和初始化HardwareCards的一个实例到变量Hardware。为了访问您分配给对象变量Hardware的信息,您需要在RackSlotAccess中引用它。
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
这篇关于从类模块VB.Net检索信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!