Rationalist
Programmer
Code:
Public Function RemoveDuplicationIntegers(ByRef TheArray As ArrayList) As ArrayList
Dim TMP1 As ArrayList
TMP1 = TheArray
Dim tmpValue1, tmpValue2 As Integer
Dim tmpfirstvalue As String = TMP1.Item(0)
Dim TMP2 As New ArrayList
TMP2.Add(tmpfirstvalue)
Dim Found As Boolean = False
For Each tmpValue1 In TMP1
Found = False
For Each tmpValue2 In TMP2
If tmpValue2 = tmpValue1 Then
Found = True
Exit For
End If
If Found = False Then
TMP2.Add(tmpValue1)
End If
Next
Next
Return (TMP2)
End Function
Error:
Collection was modified; enumeration operation may not execute.
Does anyone know what is wrong with my code?
Public Function RemoveDuplicationIntegers(ByRef TheArray As ArrayList) As ArrayList
Dim TMP1 As ArrayList
TMP1 = TheArray
Dim tmpValue1, tmpValue2 As Integer
Dim tmpfirstvalue As String = TMP1.Item(0)
Dim TMP2 As New ArrayList
TMP2.Add(tmpfirstvalue)
Dim Found As Boolean = False
For Each tmpValue1 In TMP1
Found = False
For Each tmpValue2 In TMP2
If tmpValue2 = tmpValue1 Then
Found = True
Exit For
End If
If Found = False Then
TMP2.Add(tmpValue1)
End If
Next
Next
Return (TMP2)
End Function
Error:
Collection was modified; enumeration operation may not execute.
Does anyone know what is wrong with my code?