📜  excel vba确定数组中元素的数量 - VBA代码示例

📅  最后修改于: 2022-03-11 14:51:56.383000             🧑  作者: Mango

代码示例1
'Since VBA arrays can have ANY integer value (from -2147483648 to 
'2147483647) for the lower index in the range for a rank,
'the only sure fire way to determine how many elements is in the array
'is to calculate the value:

MsgBox UBound(Arr) - LBound(Arr) + 1        '<--for elems in 1D array

MsgBox UBound(Arr, 1) - LBound(Arr, 1) + 1    '<--for rows in 2D array
MsgBox UBound(Arr, 2) - LBound(Arr, 2) + 1    '<--for cols in 2D array