Problem with arraylists in vb.net

mm1234

New member
Joined
Nov 19, 2003
Messages
4
I cant seem to remove certain items in an arraylist when I loop through it. When I debug in vs.net is seems to go through the arrTeam.remove(item) line (shown below) but does not remove the item.
And the watch still shows the original amount of items after the loop.

in icount i have these items(in this order): 1,56
in arrTeam i have these items (in this order): 1,105,56,57,36

id like to remove the items shown in icount in arrteam

please help

code:
objects initialized above


for each item in icount icount is a string array

arrTeam.Remove(item) next


thank you
 
dont use "items" with arrays. use "items" with collections. I have this to remove elements from string arrays :

Code:
    Private Sub removeElement(ByRef MyArray As String(), ByVal MyIndex As Integer)
        removes an element from an array at a given index
        Dim i As Integer
        if its the last element
        If MyIndex = UBound(MyArray) Then
            do nothing
        Else
            shift all array elements one place down
            starting with the one you want to delete (who gets overwritten)
            For i = MyIndex To UBound(MyArray) - 1
                MyArray(i) = MyArray(i + 1)
            Next
        End If
        cut the last element
        ReDim Preserve MyArray(UBound(MyArray) - 1)
    End Sub

i have no idea if its a good way of working or not, but it works for my tiny string-needs :D

Peace,
Huby.
 
Back
Top