我需要一种方法来删除数组中的最后一个元素,但我不知道数组的长度。
基本上,我需要VB版本的php array_pop函数,但是在搜索结果中似乎没有找到任何相关信息。
基本上,我需要VB版本的php array_pop函数,但是在搜索结果中似乎没有找到任何相关信息。
使用
Redim Preserve MyArray (UBound(MyArray) - 1)
Dim arr() As Long: ReDim arr(1 To 10): ReDim Preserve arr(UBound(arr)-1)
。运行时错误9:下标越界。当然,如果下限为0
,它将正常工作。但在VB6中,通常不是这样。这是一件非常好的事情。 - GSergVB6:
redim preserve arr(lbound(arr) to ubound(arr) - 1)
VB.NET:
redim preserve arr(arr.GetUpperBound(0) - 1)
List(Of Type)
呢?它更加现代化和易于操作(LINQ等...)。 - Eminem