最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP函数大全解析
时间:2026-09-20 13:40:01 编辑:袖梨 来源:一聚教程网
Array()函数返回一个数组表达式Array(list)允许数据类型:字符,数字均可实例:
<%Dim myArray()For i = 1 to 7Redim Preserve myArray(i)myArray(i) = WeekdayName(i)Next%>
返回结果:建立了一个包含7个元素的数组myArraymyArray("Sunday","Monday",......"Saturday")
CInt()函数将一个表达式转化为数字类型表达式CInt(expression)允许数据类型:任何有效的字符均可实例:
<%f = "234"response.write cINT(f) + 2%>
返回结果:236转化字符"234"为数字"234",如果字符串为空,则返回0值
CreateObject()函数建立和返回一个已注册的ACTIVEX组件的实例。表达式CreateObject(objName)允许数据类型:objName是任何一个有效、已注册的ACTIVEX组件的名字.实例:
<%Setcon=Server.CreateObject("ADODB.Connection")%>
CStr()函数转化一个表达式为字符串.表达式CStr(expression)允许数据类型:expression是任何有效的表达式。实例:
<%s = 3 + 2response.write "The 返回结果 is: " & cStr(s)%>
返回结果:转化数字“5”为字符“5”。Date()函数返回当前系统日期.表达式Date()允许数据类型:None.实例:
<%=Date%>
返回结果:9/9/00DateAdd()函数返回一个被改变了的日期。表达式DateAdd(timeinterval,number,date)允许数据类型:timeintervalisthetimeintervaltoadd;numberisamountoftimeintervalstoadd;anddateisthestartingdate.实例:
<%currentDate = #9/9/00#newDate = DateAdd("m",3,currentDate)response.write newDate%><%currentDate = #12:34:45 PM#newDate = DateAdd("h",3,currentDate)response.write newDate%>返回结果:
9/9/003:34:45PM"m"="month";"d"="day";IfcurrentDateisintimeformatthen,"h"="hour";"s"="second";
DateDiff()函数返回两个日期之间的差值。表达式DateDiff(timeinterval,date1,date2[,firstdayofweek[,firstweekofyear]])允许数据类型:timeinterval表示相隔时间的类型,如“M“表示“月”。实例:
<%fromDate = #9/9/00#toDate = #1/1/2000#response.write "There are " & _DateDiff("d",fromDate,toDate) & _" days to millenium from 9/9/00."%>返回结果:从9/9/00到2000年还有150天.Day()函数返回一个月的第几日.表达式Day(date)允许数据类型:date是任何有效的日期。实例:
<%=Day(#9/9/00#)%>
返回结果:4
FormatCurrency()函数返回表达式,此表达式已被格式化为货币值表达式FormatCurrency(Expression[,Digit[,LeadingDigit[,Paren[,GroupDigit]]]])允许数据类型:Digit指示小数点右侧显示位数的数值。默认值为-1,指示使用的是计算机的区域设置;LeadingDigit三态常数,指示是否显示小数值小数点前面的零。实例:
<%=FormatCurrency(34.3456)%>
返回结果:$34.35
相关文章
- asp文件如何打开 09-20
- ASP基础知识5BScript基本元素讲解 09-20
- 从 Deep Agents Code 源码拆解 LangChain 与 LangGraph 的生产级智能体工程 09-20
- ASP基础知识Command对象讲解 09-20
- 从数据合成到本地部署:开发垂直领域问答助手 09-20
- Spring AI 入门实践:核心机制与应用场景 09-20