首页 > 开发 > Asp > 正文

Asp函数介紹(37个常用函数)第1/2页

2020-06-20 13:14:55
字体:
来源:转载
供稿:网友
1.函数array() 
功能:创建一个数组变量 
格式:array(list) 
参数:list 为数组变量中的每个数值列,中间用逗号间隔 
例子: 
<% i = array ("1","2","3") %> 
结果: i 被赋予为数组 
2.函数Cint() 
功能:将一表达式/其它类型的变量转换成整数类型(int) 
格式:Cint(expression) 
参数:expression 是任何有效的表达式/其它类型的变量 
例子: 
<% 
f = "234" 
response.write cINT(f) + 2 
%> 
结果: 236 
函数Cint()将字符"234"转换 成整数234.如果表达式为空, 或者无效时,返回值为0; 
3.函数:Creatobject() 
功能:创建及返回一个ActiveX对象. 
格式:Creatobject(obname) 
参数bname 是对象的名称 
例子: 
<% 
Set con = Server.CreateObject("ADODB.Connection") 
%> 
结果: 
4.函数Cstr() 
功能:将一表达式/其它类型的变量转换成字符类型(string) 
格式:Cstr(expression) 
参数:expression是任何有效的表达式/其它类型的变量 
例子: 
<% 
s = 3 + 2 
response.write "The result is:" & cStr(s) 
%> 
结果:函数Cstr()将整数 5 转换 成字符"5". 
5.函数Date() 
功能:返回当前系统(server端)的日期 
格式: Date() 
参数:无 
例子<% date () %> 
结果:05/10/00 
6.函数Dateadd() 
功能:计算某个指定的时间和 
格式: dateadd(timeinterval,number,date) 
参数:timeinterval是时间单位(月,日..); number是时间间隔值,date是时间始点. 
例子: 
<% 
currentDate = #8/4/99# 
newDate = DateAdd("m",3,currentDate) 
response.write newDate 
%> <% 
currentDate = #12:34:45 PM# 
newDate = DateAdd("h",3,currentDate) 
response.write newDate 
%> 
结果: 
11/4/99 
3:34:45 PM 
其中 
"m" = "month"; 
"d" = "day"; 
如果是currentDate 格式,则, 
"h" = "hour"; 
"s" = "second"; 
7.函数Datediff() 
功能:计算某量个指定的时间差 
格式: datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]]) 
参数: timeinterval 是时间单位; date1,date2是有效的日期表达式,firstdayofweek,firstdayofyear 是任意选项. 
例子: 
<% 
fromDate = #8/4/99# 
toDate = #1/1/2000# 
response.write "There are " & _ 
DateDiff("d",fromDate,toDate) & _ 
" days to millenium from 8/4/99." 
%> 
结果:There are 150 days to millenium from 8/4/99. 
8.函数day() 
功能:返回一个整数值,对应于某月的某日 
格式: day(date) 
参数: date是一个有效的日期表达式; 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表