设计思想: 在vb中数姐最大维数是60,所以我们通过错误捕捉来处理这个问题,在这里我们用到ubound函数 public function arrayrange(marray as variant) as integer dim i as integer dim ret as integer dim errf as boolean
errf = false on error goto errhandle '判断代入的参数是否为数组 if not isarray(marray) then arrayrange = -1 exit function end if 'vb中数组最大为60 for i = 1 to 60 '用ubound函数判断某一维的上界,如果大数组的实际维数时产生超出范围错误, ' 此时我们通过resume next 来捕捉错这个错误 ret = ubound(marray, i) if errf then exit for next i '最后返回 arrayrange = ret
exit function errhandle: ret = i - 1 errf = true resume next