当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP中的函数应用方法及应用举例(一)

ASP
简单ASP论坛DIY
如何防止页面中的敏感信息被提取
asp创建对象及中文显示解决技巧
基础开发入门级:JSP与ASP的比较
数据库受到限制怎么办?
ASP初学者常犯的几个错误
Asp定时执行操作、Asp定时读取数据库(网页定时操作详解)
ASP优化:非常实用的ASP提速技巧五则
ASP教程:解决ASP脚本运行超时的方法
ASP安全:简单学习ASP连接数据库方法
简单一招用ASP实现对IE地址栏参数的判断
asp控制xml数据库的6段非常的经典代码
ASP进阶:验证身份证号是否正确的代码
ASP教程:使用ASP生成图片彩色校验码
ASP进阶:用ASP判断文件地址是否有效
ASP进阶:用asp做的简单搜索引擎代码
ASP实例 挂QQ的网页源代码ASP/PHP
ASP答疑 解决ASP脚本运行超时的方法
轻轻松松破解开别人ASP木马密码的方法
用ASP操作Access数据库 ADOX的使用

ASP中的函数应用方法及应用举例(一)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 44 ::
收藏到网摘: n/a

  1.Array()
  FUNCTION: Returns a variant containing an array.
  SYNTAX: Array(list)
  ARGUMENTS: list is a comma-delimited list of values to add to the array.
  EXAMPLE: <%
Dim myArray()
For i = 1 to 7
   Redim Preserve myArray(i)
   myArray(i) = WeekdayName(i)
Next
%>
  RESULT: Creates an Array contains 7 elements:
myArray("Sunday","Monday", ... ... "Saturday")
-------------------------------------
  
2. CInt()
  FUNCTION: Returns an expression that has been converted to an Interget subtype.
  SYNTAX: CInt(expression)
  ARGUMENTS: expression is any valid expression
  EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%>
  RESULT: 236
Converts string "234" to mathematic value 234.
If f is empty (un-initialized variable), cINT() returns 0.
-------------------------------------
  
3. CreateObject()
  FUNCTION: Creates and returns a reference to ActiveX automation object.
  SYNTAX: CreateObject(objName)
  ARGUMENTS: objName is any valid ActiveX automation object.
  EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%>
  RESULT:  
-------------------------------------
  
4. CStr()
  FUNCTION: Returns an expression that has been converted to a variant of subtype String.
  SYNTAX: CStr(expression)
  ARGUMENTS: expression is any valid expression
  EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%>
  RESULT: Converts a mathematic value 5 to a string "5".
-------------------------------------
  
5. Date()
  FUNCTION: Returns the current system date.
  SYNTAX: Date()
  ARGUMENTS: None.
  EXAMPLE: <%=Date%>
  RESULT: 8/4/99
-------------------------------------
  
6. DateAdd()
  FUNCTION: Returns a date to which a specific time interval has been added.
  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";
-------------------------------------
  
7. DateDiff()
  FUNCTION: Returns the number of intervals between two dates.
  SYNTAX: DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])
  ARGUMENTS: timeinterval is the time interval to add; date is a valid date expression; firstdayofweek and
firstweekofyear are optional values to specify the first day of the week and first week of year.
  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: There are 150 days to millenium from 8/4/99.
-------------------------------------
  
8. Day()
  FUNCTION: Returns a whole number representing the day of the month.
  SYNTAX: Day(date