ASP实用函数库(2)
发表于:2007-06-30来源:作者:点击数:
标签:
Array() FUNCTION: 返回一个数组 SYNTAX: Array(list) ARGUMENTS: 字符,数字均可 EXAMPLE: % Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i) Next %> RESULT: 建立了一个包含7个元素的数组myArray myArray("Sunday",
Array()
FUNCTION: 返回一个数组
SYNTAX: Array(list)
ARGUMENTS: 字符,数字均可
EXAMPLE: <%
Dim myArray()
For i = 1 to 7
Redim Preserve myArray(i)
myArray(i) = WeekdayName(i)
Next
%>
RESULT: 建立了一个包含7个元素的数组myArray
myArray("Sunday","Monday", ... ... "Saturday")
CInt()
FUNCTION: 将一个表达式转化为数字类型
SYNTAX: CInt(expression)
ARGUMENTS: 任何有效的字符均可
EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%>
RESULT: 236
转化字符"234"为数字"234",如果字符串为空,则返回0值
CreateObject()
FUNCTION: 建立和返回一个已注册的ACTIVEX组件的实例。
SYNTAX: CreateObject(objName)
ARGUMENTS: objName 是任何一个有效、已注册的ACTIVEX组件的名字.
EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%>
RESULT:
CStr()
FUNCTION: 转化一个表达式为字符串.
SYNTAX: CStr(expression)
ARGUMENTS: expression 是任何有效的表达式。
EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%>
RESULT: 转化数字“5”为字符“5”。
Date()
FUNCTION: 返回当前系统日期.
SYNTAX: Date()
ARGUMENTS: None.
EXAMPLE: <%=Date%>
RESULT: 8/4/99
DateAdd()
FUNCTION: 返回一个被改变了的日期。
SYNTAX: DateAdd(timeinterval,number,date)
ARGUMENTS: timeinterval is the time interval to add; number is amount of
time intervals to add; and date is the starting date.
EXAMPLE: <%
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
%>
RESULT: 11/4/99
3:34:45 PM
"m" = "month";
"d" = "day";
If currentDate is in time format then,
"h" = "hour";
"s" = "second";
DateDiff()
FUNCTION: 返回两个日期之间的差值 。
SYNTAX: DateDiff(timeinterval,date1,date2 [, firs
tdayofweek ][,
firstweekofyear]])
ARGUMENTS: timeinterval 表示相隔时间的类型,如“M“表示“月”。
EXAMPLE: <%
fromDate = #8/4/99#
toDate = #1/1/2000#
response.write "There are " & _
DateDiff("d",fromDate,toDate) & _
" days to millenium from 8/4/99."
%>
RESULT: 从8/4/99 到2000年还有 150 天.
Day()
FUNCTION: 返回一个月的第几日 .
SYNTAX: Day(date)
ARGUMENTS: date 是任何有效的日期。
EXAMPLE: <%=Day(#8/4/99#)%>
RESULT: 4
原文转自:http://www.ltesting.net