Delete values in vectors?

# Thread: Delete values in vectors?

1. David P Guest

## Delete values in vectors?

Is there any (easy?) way to delete a single value in a vector and make the others "fill the hole".<BR><BR>Example:<BR><BR>I have a vector, myVect(3). The values are:<BR>myVect(0) = "Hello"<BR>myVect(1) = "World"<BR>myVect(2) = "Blaah"<BR>myVect(3) = "Hi"<BR><BR>Is there any way delete the value "Blaah" in myVect(2) so that the vector&#039;s values would be like this:<BR>myVect(0) = "Hello"<BR>myVect(1) = "World"<BR>myVect(2) = "Hi"

2. ks
Senior Member
Join Date
Dec 1969
Posts
734

## RE: Delete values in vectors?

To remove the nth item in the array<BR><BR>Dim NewArray()<BR>size = UBound(OldArray)<BR>Redim NewArray(size - 1)<BR>For i = LBound(OldArray) To size - 1<BR> If i &#060; n Then<BR> NewArray(i) = OldArray(i)<BR> Else<BR> NewArray(i) = OldArray(i + 1)<BR> End If<BR>Next<BR>OldArray = NewArray

3. David P Guest

## Thanx!

Thanx alot!!

4. ks
Senior Member
Join Date
Dec 1969
Posts
734

## RE: Delete values in vectors?

To remove the nth item if the array is dynamic<BR><BR>size = UBound(OldArray)<BR>For i = n To size - 1<BR>OldArray(i) = OldArray(i + 1)<BR>Next<BR>Redim Preserve OldArray(size - 1)

5. David P Guest

## RE: Delete values in vectors?

Is there a way to delete the one with the value "blaa" (for example) too?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•