0

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()

8
  • What are the cb1/2 objects? Commented Jan 19, 2016 at 22:52
  • Would be useful if you include the code you used to print the values Commented Jan 19, 2016 at 23:52
  • Print code is now included Commented Jan 19, 2016 at 23:56
  • I can see the value in the Locals window, but it prints a null string. i.imgur.com/6Fg5GBv.png Is this what you're experiencing? Commented Jan 20, 2016 at 0:11
  • I get null strings printed to the immediate window and my locals window is empty. I just want to check that these arrays are storing the TextBox entries. I'm able to store the entries in other variables and print to the immediate window, just struggling with the arrays Commented Jan 20, 2016 at 0:25

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.