ASP中常用的函数和详细说明
更新时间:2007年03月02日 00:00:00 作者:
20.函数month()
功能:返回一数值, 表示月份
格式:month(time)
参数:time是日期变量
例子<% =month(#08/09/99) %>
结果:9
21.函数monthname()
功能:返回月份的字符串(名称).
格式:Monthname(date [,abb])
参数: date是日期变量,abb=true时 则月份的缩写,
例子:
<% =monthname(#4/5/99#) %>
结果:April
22.函数Now()
功能:返回系统的当前时间和日期.
格式:now()
参数:无
例子:
<% =now() %>
结果: 05/10/00 8:45:32 pm
23.函数:replace()
功能:在字符串中查找,替代指定的字符串.
格式:replace(strtobesearched,strsearchfor,strreplacewith [,start[,count[,compare]]])
参数:strtobesearched是字符串; strsearchfor是被查找的子字符串;strreplacewith 是用来替代的子字符串.start,count,compare 是任意选项.
例子:
<%
strtest="this is an apple."
response.write replace(strtest,"apple","orange")
%>
结果:this is an orange.
24.函数right()
功能:截取一个字符串的后部分
格式:right(string,length)
参数:string字符串,length截取的长度.
例子:
<%
strtest="this is a test!"
response.write right(strtest,3)
%>
结果:st!
25.函数rnd()
功能:返回一个随机数值
格式:rnd[(number)]
参数:number是任意数值.
例子:
<%
randomize()
response.write rnd()
%>
结果:0/1数值之一,无randomize(), 则不能产生随机数.
26.函数round()
功能:完整数值
格式:round(expression[,numright])
参数:expression数字表达式;numright任意选项.
例子:
<%
i=12.33654
response.write round(i)
%>
结果: 12
27.函数rtrim()
功能:去掉字符串后的空格.
格式:rtrim(string)
参数:string 是字符串
例子:
<%
response.write rtrim("this is a test! ")
%>
结果:this is a test!
28.函数second()
功能:返回一个整数值.
格式:second(time)
参数:time是一个有效的时间表达式;
例子lt;% =second(# 12:28:30#) %>
结果:30
29.函数strReverse()
功能:返回与原字符串排列逆向的字符串.
格式:strreverse(string)
参数:string是字符串
例子<% =strreverse("this is a test!")
结果:!tset a si siht
30.函数time()
功能:返回当前系统的时间值.
格式:time()
参数:无
结果:9:58:28 Am
31.函数trim()
功能:删去字符串前,后的空格.
格式:trim(string)
参数:string 字符串.
例子:
<%
strtest=" this is a test! "
response.write trim(strtest)
%>
结果:this is a test!
32.函数UBound()
功能:返回一个数组的上界.
格式:Ubound(expression [,dimension])
参数:expression 是数组表达式/数组变量,dimension 是任意项
例子:
<%
i = array("1","2","3")
response.write ubound(i)
%>
结果: 2
33.函数:UCase()
功能:将一字符类型变量的字符全部变换成大写字符.
格式:Ucase(string)
参数:string是字符串变量
例子:
<%
str="THIS is Lcase!"
response.write Lcase(str)
%>
结果:THIS IS LCASE!
34.函数Vartype()
功能:返回变量的常量代码(整数)
格式:Vartype(varname)
参数:varname是任何类型的变量名称.
例子:
<%
i=5
response.write vartype(i)
%>
结果:2 (2表示整数,须要参考ASP常量代码.)
35.函数Weekday()
功能:返回一个整数,对应一周中的第几天.
格式:Weekday(date [,firstofweek])
参数: date为日期变量,firstofweek为任选项.
例子:
<%
d= # 5/9/00 #
response.write weekday(d) %>
结果:3(3 表示是星期二)
36.函数weekdayname()
功能:返回字符串,对应星期几.
格式:weekdayname(weekday[,abb[,firstdayofweek]])
参数:weekday为日期变量,abb,firstdayofweek为任选项.
例子:
<%
d = #8/4/99#
response.write weekdayname(d)
%>
结果: Wednesday
37.函数year()
功能:返回日期表达式所在的年份.
格式:year(date)
参数: date是有效的日期表达式
例子:
<% =year(#8/9/99#) %>
结果:1999
38.函数Mod()功能:取余数.
例子:3 Mod 2
结果:1
我先介绍一下Split函数的用法:
返回值数组 = Split("字符串","分割符")
39.split函数的应用
作者:李春光 转贴自:本站原创 点击数:113 文章录入:
split 是一个分隔字符串的函数,它的作用是把用特定分隔符隔开的字符串转化为一个数组,这在编程中用的比较多,如上传多张图片,在数库中仅能用一个字段存储的情况下,split就起作用了,下面是一个具体的例子,和数组结合使用.
<%
dim str1
str1="icerain|fengling|windbell|"
aryReturn=split(str1,"|")
response.write "返回的是否为数组"&IsArray(aryReturn)
response.write "<br>"
for i=LBound(aryReturn) TO UBound(aryReturn)
response.write aryReturn(i)
response.write "<br>"
next
response.end
%>
Rnd()
函数产生一个随机数.
表达式 Rnd [ (number) ]
实例: <%
Randomize()
response.write RND()
%>
返回结果: 任何一个在0 到 1 之间的数
最新评论