|
Remove 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)
|