deleting an element from an array

hi there, i m having problems deleting an element from an array. my function is as follows: the problem is that my array deletes the number i wanna delete bt copies the last value in the array twice ie. if i want to delete 54 from my array : 33 54 71 i get 33 71 71. can anyone please help.

private function delete(ByVal array as Integer(),byVal num as Integer) as Integer()

for count=0 to UBound(array)
redim preserve array(length-1) 'length a global variable
for(j=index to UBound(array))
return array
end if


  • something like this....

    Public Sub DeleteElement(ByRef r_Arr as integer(), ByVal v_Element as integer)

    Dim l_Start As Integer = Array.IndexOf(r_Arr, v_Element)

    For l_Loop As Integer = l_Start To r_Arr.Length - 2
    r_Arr(l_Loop) = r_Arr(l_Loop) + 1

    ReDim Preserve r_Arr(r_Arr.Length - 2)

    End Sub[/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion