ASP常用函数详解
Array()
FUNCTION: 返回一个数组
SYNTAX: Array(list)
ARGUMENTS: 字符,数字均可
EXAMPLE: <%
Dim myArray()
For i = 1 to 7
Redim Preserve myArray(i)
myArray(i) = WeekdayName(i)
Next
%[/IMG]
RESULT: 建立了一个包含7个元素的数组myArray
myArray("Sunday","Monday", ... ... "Saturday")
CInt()
FUNCTION: 将一个表达式转化为数字类型
SYNTAX: CInt(expression)
ARGUMENTS: 任何有效的字符均可
EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%[/IMG]
RESULT: 236
转化字符"234"为数字"234",如果字符串为空,则返回0值
CreateObject()
FUNCTION: 建立和返回一个已注册的ACTIVEX组件的实例。
SYNTAX: CreateObject(objName)
ARGUMENTS: objName 是任何一个有效、已注册的ACTIVEX组件的名字.
EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%[/IMG]
RESULT:
CStr()
FUNCTION: 转化一个表达式为字符串.
SYNTAX: CStr(expression)
ARGUMENTS: expression 是任何有效的表达式。
EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%[/IMG]
RESULT: 转化数字“5”为字符“5”。
Date()
FUNCTION: 返回当前系统日期.
SYNTAX: Date()
ARGUMENTS: None.
EXAMPLE: <%=Date%[/IMG]
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
%[/IMG]
<%
currentDate = #12:34:45 PM#
newDate = DateAdd("h",3,currentDate)
response.write newDate
%[/IMG]
RESULT: 11/4/99
3:34:45 PM
"m" = "month";
"d" = "day";
If currentDate is in time format then,
"h" = "hour";
相关文档:
Dim xmlDoc
NewsConfigFile=server.MapPath("/test.xml")
Set xmlDoc=Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0")
If Not xmlDoc.load(NewsConfigFile) Then
'XmlDoc.loadxml "<?xml version=""1.0"" encoding=""gb2312""?><NewscodeInfo/>"
response.Write("不存在数据")
& ......
asp文件搜索
<%
'*************Set newsearch=new SearchFile '声明 *************
'*************newsearch.Folder="F:+E:"'传入搜索源*************
'*************newsearch.keyword="汇编" '关键词*************
'*************newsearch.Search &nbs ......
<%
function decrypt(dcode)
dim texts
dim i
for i=1 to len(dcode)
texts=texts & chr(asc(mid(dcode,i,2))-i)
next
decrypt=texts
end function
function encrypt(ecode)
dim texts
dim i
for i=1 to len(ecode)
texts=texts & chr(asc(mid(ecode,i,2))+i)
next
en ......
2、纯ASP代码生成图表函数——柱图
<%
dim total(12,2)
total(1,1)=56
total(2,1)=7
total(3,1)=-7
total(4,1)=0
total(5,1)=16
total(6,1)=10
total(7,1)=14
total(8,1)=7
total(9,1)=9
total(10,1)=7
total(11,1)=11
total(12,1)=14
total(1,2)="地理"
total(2,2)="化学"
total(3,2)="历史 ......
4、纯ASP代码生成图表函数——饼图
<%dim total(7,1)
total(1,0)="中国经营报"
total(2,0)="招聘网"
total(3,0)="51Job"
total(4,0)="新民晚报"
total(5,0)="新闻晚报"
total(6,0)="南方周末"
total(7,0)="羊城晚报"
total(1,1)=200
total(2,1)=1200
total(3,1)=900
total(4,1)=600
total(5,1)=1 ......