教程集 www.jiaochengji.com
教程集 >  脚本编程  >  vbscript  >  正文 asp中ubound与lubound用法解析

asp中ubound与lubound用法解析

发布时间:2014-10-19   编辑:jiaochengji.com
本文介绍了asp中ubound与lubound函数的用法,ubound函数返回一个

来看ubound函数。
返回一个 long 型数据,其值为指定的数组维可用的最大下标。

语法
ubound(arrayname[, dimension])
ubound 函数的语法包含下面部分:
部分 描述
arrayname 必需的。数组变量的名称,遵循标准变量命名约定。
dimension 可选的;variant (long)。指定返回哪一维的上界。1 表示第一维,2 表示第二维,以此类推。如果省略 dimension,就认为是 1。

说明
ubound 函数与 lbound 函数一起使用,用来确定一个数组的大小。lbound 用来确定数组某一维的上界。

对具有下述维数的数组而言,ubound 的返回值见下表:
 

dim a(1 to 100, 0 to 3, -3 to 4)
语句 返回值
ubound(a, 1) 100
ubound(a, 2) 3
ubound(a, 3) 4

asp ubound() 函数的使用 返回数组的指示维度的最大可用下标。

例如:
 

复制代码 代码示例:
<%
chkitems = trim(request("chk"))
if chkitems <> "" then
chkitem = split(chkitems,",")
'for i=0 to ubound(chkitem)
'response.write(chkitem(i) & "<br />")
'next
else
response.write("请选择一个投票项!")
end if
%>
 

因为split 函数将获取来的复选框值按照分隔符‘ ,'分割,以一个数组的数据格式存放起来,现在要依次输出有哪些复选项被选中,用的是一个for循环,for 循环变量的确定就得用ubound函数。

您可能感兴趣的文章:

关键词: ubound  vbs函数   
[关闭]
~ ~