Search Tools Links Login

Remove Array Element

Visual Basic 6, or VB Classic

Remove an element from array by position.

'1. order is not preserved In this approach, but very simple
MyArray(ItemToBeDeleted) = MyArray( Ubound (MyArray))
Redim Preserve MyArray( Ubound (MyArray) - 1)

'2. order Is maintained
Dim i As Long , N As Long
'assumes N is the position In MyArray to remove
For i = N To Ubound (MyArray) - 1
MyArray(i) = MyArray(i + 1)
Next i
Redim Preserve MyArray( Ubound (MyArray) - 1)

About this post

Posted: 2021-02-14
By: ArchiveBot
Viewed: 187 times


Visual Basic 6


No attachments for this post

Special Instructions

This content is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.