79076270

Date: 2024-10-10 22:02:33
Score: 0.5
Natty:
Report link

Changing the append() function like so fixes the issue:

Public Sub append(new_card_no As String, new_entry_time As Date, new_exit_time As Date)
    If UBound(elements) < size + 1 Then
        ReDim Preserve elements(size * 2)
        
    End If
    
    Dim new_park As New park

    new_park.card_no = new_card_no
    new_park.entry_time = new_entry_time
    new_park.exit_time = new_exit_time
    
    Set elements(size) = new_park
    
    size = size + 1
End Sub

As Chris and Tim pointed out, the park objects in elements default to nothing and need to be instantiated before their properties can be set.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Clayt