YsoL8
YsoL8

Reputation: 2214

VB delete last element in dynamic array

I need a way to delete the last element in an array when I don't know how big the array is.

Basically I need the VB version of php array_pop, but nothing relevant seems to be appearing in search results.

Upvotes: 5

Views: 18904

Answers (2)

GSerg
GSerg

Reputation: 78185

VB6:

redim preserve arr(lbound(arr) to ubound(arr) - 1)

VB.NET:

redim preserve arr(arr.GetUpperBound(0) - 1)

Upvotes: 6

heximal
heximal

Reputation: 10517

use

Redim Preserve MyArray (UBound(MyArray) - 1)

Upvotes: 18

Related Questions