Reputation: 19
I have several classes containing details about an onsite switchboard. I am using a Userform to store data in the variables declared in each class. I am struggling to store the data in any of my arrays. Am I going the right way about declaring these variables? Here's an example of one of my classes:
Dim pEquipID(3) As String
Dim pIr(3) As Integer
Dim pIm(3) As Integer
Dim pTripCurrent(3) As Integer
Dim pTripTime(3) As Integer
Dim pIsc(3) As Integer
Public Property Let EquipID(index As Integer, value As String)
pEquipID(index) = value
End Property
Public Property Let Ir(index As Integer, value As Integer)
pIr(index) = value
End Property
Public Property Let Im(index As Integer, value As Integer)
pIm(index) = value
End Property
Public Property Let TripCurrent(index As Integer, value As Integer)
pTripCurrent(index) = value
End Property
Public Property Let TripTime(index As Integer, value As Integer)
pTripTime(index) = value
End Property
Public Property Let Isc(index As Integer, value As Integer)
pIsc(index) = value
End Property
Public Property Get EquipID(index As Integer) As String
EquipID(index) = pEquipID(index)
End Property
Public Property Get Ir(index As Integer) As Integer
Ir(index) = pIr(index)
End Property
Public Property Get Im(index As Integer) As Integer
Im(index) = pIm(index)
End Property
Public Property Get TripCurrent(index As Integer) As Integer
TripCurrent(index) = pTripCurrent(index)
End Property
Public Property Get TripTime(index As Integer) As Integer
TripTime(index) = pTripTime(index)
End Property
Public Property Get Isc(index As Integer) As Integer
Isc(index) = pIsc(index)
End Property
And this is how I am storing the data:
Private Sub Enter1_Click()
'create class variables
Dim Transformer1 As cTransformer
Set Transformer1 = New cTransformer
Dim Fuse1 As cFuse
Set Fuse1 = New cFuse
Dim CircuitBreaker1 As cCircuitBreaker
Set CircuitBreaker1 = New cCircuitBreaker
Dim Pump1 As cPump
Set Pump1 = New cPump
Dim Cable1 As cCable
Set Cable1 = New cCable
'store circuit breaker entries
CircuitBreaker1.EquipID(0) = CB1ID1.value
CircuitBreaker1.EquipID(1) = CB2ID1.value
CircuitBreaker1.Ir(0) = Cb1Ir1.value
CircuitBreaker1.Ir(1) = CB2Ir1.value
CircuitBreaker1.Im(0) = CB1Im1.value
CircuitBreaker1.Im(1) = CB2Im1.value
CircuitBreaker1.Isc(0) = CB1Isc1.value
CircuitBreaker1.Isc(1) = CB2Isc1.value
CircuitBreaker1.TripCurrent(0) = CB1trip1.value
CircuitBreaker1.TripCurrent(1) = CB2trip1.value
CircuitBreaker1.TripTime(0) = CB1time1.value
CircuitBreaker1.TripTime(1) = CB2time1.value
When I debug.print the CircuitBreaker array the terminal prints blank values. I use a loop like this to print each array:
Dim count As integer
For count = 0 To 1 Step 1
Debug.Print CircuitBreaker1.EquipID(count)
Next count
Note that this print statement is inside Enter1_click()
Upvotes: 0
Views: 156
Reputation: 1423
Your Property Get is incorrect. Instead of:
Public Property Get EquipID(index As Integer) As String
EquipID(index) = pEquipID(index)
End Property
... it should be:
Public Property Get EquipID(index As Integer) As String
EquipID = pEquipID(index)
End Property
Upvotes: 1