array er låst?
Hej der!Jeg sveder lidt over at jeg ikke kan få lov til at Redim når jeg fjerner et stationobject fra min kø i deQueue proceduren.
error message: array cannot be changed or is locked.
Jeg går ud fra at det er et problem med Byval/Byref, men kan ikke få skidtet til at funke.
Er der en der kan hjælpe?
Kode:
Option Explicit
Private QueueEmpty
Private mlCount1 As Long
Private QueuedStations() As clsStation
Public Function ClearQueue()
QueueEmpty = True
ReDim QueuedStations(0) \'<- Error her
End Function
Public Function Enqueue(ByRef thisStation As clsStation)
\'adds a reference to the specified station to the queue
If Not QueueEmpty Then
ReDim Preserve QueuedStations(UBound(QueuedStations) + 1)
Else
QueueEmpty = False
End If
Set QueuedStations(UBound(QueuedStations)) = thisStation
thisStation.queueNumber = UBound(QueuedStations)
thisStation.currentPallet.PalletStatus = Waiting
frmPalMan.updatePalletStatus thisStation
End Function
Public Function Dequeue(thisStation As clsStation)
\'Removes the specified station from the queue
If UBound(QueuedStations) = 0 Then
ClearQueue
Else
For mlCount1 = thisStation.queueNumber To UBound(QueuedStations) - 1
Set QueuedStations(mlCount1) = QueuedStations(mlCount1 + 1)
QueuedStations(mlCount1).queueNumber = mlCount1
Next mlCount1
thisStation.queueNumber = -1
ReDim Preserve QueuedStations(UBound(QueuedStations) - 1) \' <- ... eller Her
End If
thisStation.currentPallet.PalletStatus = ready
frmPalMan.updatePalletStatus thisStation
End Function
Public Function getNext() As clsStation
Set getNext = QueuedStations(0)
Dequeue QueuedStations(0)
End Function