ASP中的函数说明[2]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 asthlon 的 blog

 function:判断一对象是否为日期,返回布尔值
 syntax:isdate(expression)
 arguments:expression is any valid expression.
 example:<%
strtest = "8/4/99"
response.write isdate(strtest)
%>
 result:true

isempty()
 function:判断一对象是否初始化,返回布尔值.
 syntax:isempty(expression)
 arguments:
 example:<%
dim i
response.write isempty(i)
%>
 result:true

isnull()
 function:判断一对象是否为空,返回布尔值.
 syntax:isnull(expression)
 arguments:
 example:<%
dim i
response.write isnull(i)
%>
 result:false

isnumeric()
 function:判断一对象是否为数字,返回布尔值.
 syntax:isnumeric(expression)
 arguments:
 example:<%
i = "345"
response.write isnumeric(i)
%>
 result:true
就算数字加了引号,asp还是认为它是数字。

isobject()
 function:判断一对象是否为对象,返回布尔值.
 syntax:isobject(expression)
 arguments:
 example:<%
set con = server.createobject("adodb.connection")
response.write isobject(con)
%>
 result:true

lbound()
 function:返回指定数组维的最小可用下标.
 syntax:lbound(arrayname [, dimension])
 arguments:; dimension 指明要返回哪一维下界的整数。使用 1 表示第一维,2 表示第二维,以此类推。如果省略 dimension 参数,默认值为 1.
 example:<%
i = array("monday","tuesday","wednesday")
response.write lbound(i)
%>
 result:0

lcase()
 function:返回字符串的小写形式
 syntax:lcase(string)
 arguments:string is any valid string expression.
 example:<%
strtest = "this is a test!"
response.write lcase(strtest)
%>
 result:this is a test!

left()
 function:返回字符串左边第length个字符以前的字符(含第length个字符).
 syntax:left(string, length)
 arguments:
 example:<%
strtest = "this is a test!"
response.write left(strtest, 3)
%>
 result:thi

len()
 function:返回字符串的长度.
 syntax:len(string | varname)
 arguments:
 example:<%
strtest = "this is a test!"
response.write len(strtest)
%>
 result:15

ltrim()
 function:去掉字符串左边的空格.
 syntax:ltrim(string)
 arguments:
 example:<%
strtest = " this is a test!"
response.write ltrim(strtest)
%>
 result:this is a test!

mid()
 function:返回特定长度的字符串(从start开始,长度为length).
 syntax:mid(string, start [, length])
 arguments:
 example:<%
strtest = "this is a test! today is monday."
response.write mid(strtest, 17, 5)
%>
 result:today

minute()
 function:返回时间的分钏.
 syntax:minute(time)
 arguments:
 example:<%=minute(#12:45:32 pm#)%>
 result:45

month()
 function:返回日期.
 syntax:month(date)
 arguments:date is any valid date expression.
 example:<%=month(#08/04/99#)%>
 result:8

monthname()
 function:returns a string identifying the specified month.
 syntax:monthname(month, [, abb])
 arguments:month is the numeric representation for a given month; abb (optional) is a boolean value used to display month abbreviation. true will display the abbreviated month name and false (default) will not show the abbreviation.
 example:<%=monthname(month(#08/04/99#))%>
 result:august

now()
 function:returns the current system date and time.
 syntax:now()
 arguments:none
 example:<%=now%>
 result:8/4/99 9:30:16 am

replace()
 function:returns a string in which a specified sub-string has been replaced with another substring a specified number of times.
 syntax:replace(strtobesearched, strsearchfor, strreplacewith [, start [, count [, compare]]])
 arguments:strtobesearched is a string expression containing a sub-string to be replaced; strsearchfor is the string expression to search for within strtobesearched; strreplacewith is the string expression to replace sub-string strsearchfor; start (optional) is the numeric character position to begin search; count (optional) is a value indicating the comparision constant.
 example:<%
strtest = "this is an apple!"
response.write replace(strtest, "apple", "orange")
%>
 result:this is an orange!

right()
 function:返回字符串右边第length个字符以前的字符(含第length个字符).
 syntax:right(string, length)
 arguments:.
 example:<%
strtest = "this is an test!"
response.write right(strtest, 3)
%>
 result:st!

rnd()
 function:产生一个随机数.
 syntax:rnd [ (number) ]
 arguments:
 example:<%
randomize()
response.write rnd()
%>
 result:任何一个在0 到 1 之间的数

round()
 function:返回按指定位数进行四舍五入的数值.
 syntax:round(expression [, numright])
 arguments:numright数字表明小数点右边有多少位进行四舍五入。如果省略,则 round 函数返回整数.
 example:<%
i = 32.45678
response.write round(i)
%>

本文关键:ASP中的函数说明
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top