一个动态数组 a,如果你已经使用redim 语句给它设定了大小,那么在此之后使用 ubound(a) 就可以得到它的上边界。
如果你没有使用 redim 语句给它设定大小,直接使用 ubound(a) 函数,那么运行时会报错,并会中断程序的执行.我们恰恰利用这一点,可以知道这个数组还没有任何元素。于此同时,我们却不想程序中断执行,那么可以在 ubound(a) 函数执行前加上一句
复制代码 代码如下:
复制代码
on error resume next
on error resume next
把本功能写成一个函数 function get_element_count_of_one_aray(name_of_aray)
复制代码 代码如下:
复制代码
on error resume next
uper_bound_of_aray=ubound(name_of_aray)
if err then
get_element_count_of_one_aray=0
else
get_element_count_of_one_aray=uper_bound_of_aray+1
end if
end function
on error resume next
uper_bound_of_aray=ubound(name_of_aray)
if err then
get_element_count_of_one_aray=0
else
get_element_count_of_one_aray=uper_bound_of_aray+1
end if
end function
最后
以上就是贪玩网络最近收集整理的关于asp 得到动态数组中元素的个数的全部内容,更多相关asp内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复