You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove method it doesn't remove the only element of a 1 length array
I made a script that stores various string elements in a BetterArray object and then with a For...Next structure if a certain condition is met it removes one specific element of the array with the .Remove(Index) method. The problem is when the BetterArray object remains with 1 element and I want to remove it because the mentioned condition is met again at that point. BetterArray.Remove(0) simply returns the same BetterArray with one element.
To Reproduce
Steps to reproduce the behavior:
Simply run the following Sub procedure: Sub BetterArrayTest() Dim BA As New BetterArray BA.Items = Array("Hello") BA.Remove 0 Debug.Print BA.ToString End Sub
See the result in the Inmediate Window (see screenshot). It doesn't remove the "Hello" element.
Expected behavior
If a BetterArray object has one element (Lenght = 1), then the syntax BetterArray.Remove(0) really remove that element.
Screenshots
Operating System:
Windows 7 64 bits
Host Application:
MS Excel
Additional context
The problem is only when the BetterArray object has one element. If it has more than one element the .Remove(0) method effectively removes the first element of the array.
The text was updated successfully, but these errors were encountered:
kennyk4silva
changed the title
[BUG]
[BUG] Remove method it doesn't remove the only element of a 1 length array
Aug 28, 2021
kennyk4silva
changed the title
[BUG] Remove method it doesn't remove the only element of a 1 length array
Remove method it doesn't remove the only element of a 1 length array
Aug 28, 2021
Hi @Senipah, thank you so much for your great effort making that excellent class. I'm using it a lot processing txt files and arrays in a fast and effective way. I will let you know if I found another issue. Greetings from Venezuela.
Remove method it doesn't remove the only element of a 1 length array
I made a script that stores various string elements in a BetterArray object and then with a For...Next structure if a certain condition is met it removes one specific element of the array with the .Remove(Index) method. The problem is when the BetterArray object remains with 1 element and I want to remove it because the mentioned condition is met again at that point. BetterArray.Remove(0) simply returns the same BetterArray with one element.
To Reproduce
Steps to reproduce the behavior:
Simply run the following Sub procedure:
Sub BetterArrayTest()
Dim BA As New BetterArray
BA.Items = Array("Hello")
BA.Remove 0
Debug.Print BA.ToString
End Sub
See the result in the Inmediate Window (see screenshot). It doesn't remove the "Hello" element.
Expected behavior
If a BetterArray object has one element (Lenght = 1), then the syntax BetterArray.Remove(0) really remove that element.
Screenshots
Operating System:
Host Application:
Additional context
The problem is only when the BetterArray object has one element. If it has more than one element the .Remove(0) method effectively removes the first element of the array.
The text was updated successfully, but these errors were encountered: