|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
虽然很简单但也改过很多版本
Function Array1D_Expand_(arr1D, ByVal iExpectMinUbound As Long, Optional ByVal iCountAdd As Long = 16) As Boolean
'扩展数组空间 需保证arr1D为一维数组
'使用方法:Call Array1D_Expand_(arr, iExpectMinUbound)
'iExpectMinUbound: 当前期望的Ubound,用于判断是否需要扩展
'如果iExpectMinUbound <= iUB则不扩展
'iCountAdd:数据总量较小时可有效降低扩展次数,可使用默认值
Dim iLB As Long, iUB As Long
iUB = UBound(arr1D)
If iExpectMinUbound <= iUB Then Exit Function
iLB = LBound(arr1D)
If iUB < 256 Then
iUB = iLB - 1 + 2 * (iExpectMinUbound - iLB + 1) + iCountAdd
Else
iUB = iLB - 1 + (1.3 * (iExpectMinUbound - iLB + 1) + 256) And &HFFFFFF00
End If
ReDim Preserve arr1D(iLB To iUB)
Array1D_Expand_ = True
End Function
|
|