Hi!
I am trying to delete items in a list that have a location outside an 80x80 rectangle. Either if I create a temporary list or not, I get this error:
Collection was modified; enumeration operation may not execute.
It looks like the tempList.Count = 0, but I'm not sure why. (The DeleteExtra() sub is used in a timer.tick event.)
Thanks in advance. ~NinjaNicCode:Private Sub DeleteExtra() bmpList(0).LocationX = 2000 'Just to test! Dim TempList As List(Of bmp) = bmpList For Each bmp In TempList If bmp.LocationX < 0 Or bmp.LocationY < 0 Or bmp.LocationX > 80 Or bmp.LocationY > 80 Then bmpList.Remove(bmp) End If Next End Sub




Reply With Quote
