感谢这个论坛上的精彩帮助,我成功地使一个班级成为另一个班级的财产。我还能够将类b值的变量传递给A类。
现在我真正需要做的是在A类中创建一个数组或类b的集合。我开始用一个集合做这个但放弃了,现在我试图用一个没有成功的数组来做。我知道数组的大小,所以我为这个样本预定了3。实际上它会有更多,但我仍然需要完成基本步骤。谢谢你们的帮助,这里是我的代码。
Public Sub tester()
Dim cotton As catDist
Dim z000123 As cRegistrant
Set cotton = New catDist
Set z000123 = New cRegistrant
With cotton
.selfWorth = "Cottonseed Products"
.Active = True
.Q1 = 4.2
.Q2 = 1.2
.Q3 = 8
.Q4 = 0.3
End With
z000123.feedIngColADD (cotton)
Debug.Print z000123.feedIngCol(1).selfWorth
End Sub
catDist class
Private pActive As Boolean
Private PselfWorth As String
Private pQ1 As Double
Private pQ2 As Double
Private pQ3 As Double
Private pQ4 As Double
'*******************
'Active Property
'******************
Public Property Get Active() As Boolean
Active = pActive
End Property
Public Property Let Active(Value As Boolean)
pActive = Value
End Property
'*******************
' Self Worth
'******************
Public Property Get selfWorth() As String
selfWorth = PselfWorth
End Property
Public Property Let selfWorth(Value As String)
PselfWorth = Value
End Property
'************************
' First Quarter Property
'************************
Public Property Get Q1() As Double
Q1 = pQ1
End Property
Public Property Let Q1(Value As Double)
pQ1 = Value
End Property
'************************
' Second Quarter Property
'************************
Public Property Get Q2() As Double
Q2 = pQ2
End Property
Public Property Let Q2(Value As Double)
pQ2 = Value
End Property
'************************
' Third Quarter Property
'************************
Public Property Get Q3() As Double
Q3 = pQ3
End Property
Public Property Let Q3(Value As Double)
pQ3 = Value
End Property
'************************
' Fourth Quarter Property
'************************
Public Property Get Q4() As Double
Q4 = pQ4
End Property
Public Property Let Q4(Value As Double)
pQ4 = Value
End Property
最后,我试图制作的初级注册人。最终,注册人将拥有5个阵列,每个阵列都有不同数量的catDist对象。我需要能够在各种数组之间传递并获取值和第四个值。
Private pRegistNum As String
Private pCatDist As catDist
Private pfeedIngCol(3) As catDist
Public Property Get registNum() As String
registNum = pRegistNum
End Property
Public Property Let registNum(registration As String)
pRegistNum = registration
End Property
Public Property Get testCat() As catDist
Set testCat = pCatDist
End Property
Public Property Set testCat(cat As catDist)
Set pCatDist = cat
End Property
Public Property Get feedIngCol() As catDist
Set feedIngCol = pfeedIngCol
End Property
Public Sub feedIngColADD(cat As catDist)
Select Case cat
Case cat.selfWorth = "Cottonseed Products": Set pfeedIngCol(1) = cat
Case cat.sefWorth = "Maize (Corn Products)": Set pfeedIngCol(2) = cat
Case cat.selfWorth = "Peanut Products": Set pfeedIngCol(3) = cat
End Select
End Sub