通过实例讲解来学习ASP中的函数
Array()
作用:返回一个数组
语法:Array(list)
适用的类型:字符,数字均可
<% Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i) Next %>
结果:建立了一个包含7个元素的数组myArray
myArray("Sunday","Monday", ... ... "Saturday")
CInt()
作用:将一个表达式转化为数字类型
语法:CInt(表达式)
适用的类型:任何有效的字符均可
<% f = "234" response.write cINT(f) + 2 %>
结果:236
转化字符"234"为数字234,如果字符串为空,则返回0值
CreateObject()
作用: 建立和返回一个已注册的ACTIVEX组件的实例。
语法: CreateObject(objName)
适用的类型: objName 是任何一个有效、已注册的ACTIVEX组件的名字.
<% Set con = Server.CreateObject("ADODB.Connection") %>
CStr()
作用: 转化一个表达式为字符串.
语法: CStr(expression)
适用类型: expression 是任何有效的表达式
<% s = 3 + 2 response.write("The 结果 is: " & cStr(s)) %>
结果: 转化数字5为字符“5”。
Date()
作用: 返回当前系统日期.
语法: Date()
适用的类型: None.
<%=Date%>
结果: 8/4/99
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";
当当前日期格式为time,那么
"h" = "hour";
"s" = "second";
DateDiff()
作用: 返回两个日期之间的差值 。
语法: DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear >>)
说明: timeinterval 表示相隔时间的类型,如“M“表示“月”。
<% fromDate = #8/4/99# toDate = #1/1/2000# response.write("There are " & _ DateDiff("d",fromDate,toDate) & _ " days to millenium from 8/4/99." %>
结果: There are150daysto millenium from 8/4/99.
Day()
作用: 返回一个月的第几日 .
语法: Day(
- 上一篇文章: 没有了
- 下一篇文章: VB.NET实现窗体图标最小化到状态栏











文章评论
只显示最新5条。评论内容只代表网友观点,与本站立场无关!查看完整内容