I am developing a set of class modules in VBA for Excel. One class, representing a Process Unit in an industrial plant, has to hold information about its linkages to other instances of the same class. I am able to build an array in one unit that holds the linked units but I now want to associate a numerical value with each linkage.
My question is how can I do this cleanly. Ideally I would do it when setting the link but at the moment all I seem to be able to do is pass the identity of the other process unit rather than its identity and the associated value at the same time.
The relevant bits of the class code are as follows where iPrerequisiteDelay is the value I want to associate with the link
Dim Prerequisite() As clsProcessUnit, iPrerequisiteDelay() As Integer
Private piPrerequisites As Integer, piInterruptions As Integer, piLoop As Integer
Public Property Let Requires(Unit As clsProcessUnit)
' Create a link from this unit to a unit it needs to be Up for this one to operate
piPrerequisites = piPrerequisites + 1
' ReDim iPrerequisiteDelay(piPrerequisites)
Set Prerequisite(piPrerequisites) = Unit
' iPrerequisiteDelay(piPrerequisites) = iDelay
The test code I have used to instantiate the units and set their links is as follows
Dim UnitA As clsProcessUnit
Dim UnitB As clsProcessUnit
Dim UnitC As clsProcessUnit
Set UnitA = New clsProcessUnit
Set UnitB = New clsProcessUnit
Set UnitC = New clsProcessUnit
UnitA.Name = "First Unit"
UnitB.Name = "Second Unit"
UnitC.Name = "Third Unit"
UnitB.Requires = UnitA
UnitC.Requires = UnitB
Ideally, I would like to use one statement to set the name and the numeric value associated with the link, where I use the "UnitA.Requires = " etc.