Asp函数介紹(37个常用函数)

来源:asp之家 时间:2011-04-11 11:06:00 

1.函数array() 
功能:创建一个数组变量 
格式:array(list) 
参数:list 为数组变量中的每个数值列,中间用逗号间隔 
例子: 

<% i = array ("1","2","3") %>  
结果: i 被赋予为数组 
2.函数Cint() 
功能:将一表达式/其它类型的变量转换成整数类型(int) 
格式:Cint(expression) 
参数:expression 是任何有效的表达式/其它类型的变量 
例子:  

<%  
f = "234"  
response.write cINT(f) + 2  
%> 
结果: 236 
函数Cint()将字符"234"转换 成整数234.如果表达式为空, 或者无效时,返回值为0; 
3.函数:Creatobject() 
功能:创建及返回一个ActiveX对象. 
格式:Creatobject(obname) 
参数bname 是对象的名称 
例子:  

<%  
Set con = Server.CreateObject("ADODB.Connection")  
%> 
结果: 
4.函数Cstr() 
功能:将一表达式/其它类型的变量转换成字符类型(string) 
格式:Cstr(expression) 
参数:expression是任何有效的表达式/其它类型的变量 
例子: 

<%  
s = 3 + 2  
response.write "The result is:" & cStr(s)  
%> 
结果:函数Cstr()将整数 5 转换 成字符"5". 
5.函数Date() 
功能:返回当前系统(server端)的日期 
格式: Date() 
参数:无 
例子

<% date () %>  
结果:05/10/00 
6.函数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"; 
如果是currentDate 格式,则, 
"h" = "hour"; 
"s" = "second"; 
7.函数Datediff() 
功能:计算某量个指定的时间差 
格式: datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]]) 
参数: timeinterval 是时间单位; date1,date2是有效的日期表达式,firstdayofweek,firstdayofyear 是任意选项. 
例子:  

<%  
fromDate = #8/4/99#  
toDate = #1/1/2000#  
response.write "There are " & _  
DateDiff("d",fromDate,toDate) & _  
" days to millenium from 8/4/99."  
%> 
结果:There are 150 days to millenium from 8/4/99. 
8.函数day() 
功能:返回一个整数值,对应于某月的某日 
格式: day(date) 
参数: date是一个有效的日期表达式; 
例子

<% =date(#8/4/99#) %> 
结果:4 
9.函数formatcurrency() 
功能:转换成货币格式 
格式: formatcurrency(expression [,digit[,leadingdigit[,paren[,groupdigit]]]]) 
参数: expression 是有效的数字表达式;digit表示小数点后的位数;leadingdigit,paren,groupdigit是任意选项. 
例子

<%=FormatCurrency(34.3456)%> 


结果34.35 

标签:Asp,函数
0
投稿

猜你喜欢

  • 从MySQL数据库表中取出随机数据的代码

    2023-11-14 09:53:58
  • JavaScript 页面编码与浏览器类型判断代码

    2024-04-08 10:54:03
  • python实现定时播放mp3

    2022-01-29 22:25:21
  • Python 程序报错崩溃后如何倒回到崩溃的位置(推荐)

    2021-01-08 16:14:34
  • 无阻塞加载脚本分析[全]

    2024-04-17 10:25:35
  • Python入门之三角函数tan()函数实例详解

    2022-04-12 18:41:59
  • 导致python中import错误的原因是什么

    2023-08-21 05:24:04
  • MySql .frm数据库文件导入的问题

    2024-01-18 19:08:09
  • selenium环境搭建及基本元素定位方式详解

    2021-12-09 14:53:33
  • Python文本终端GUI框架示例详细讲解

    2021-05-19 22:47:12
  • python基础教程之获取本机ip数据包示例

    2022-09-28 13:31:45
  • 学习Python爬虫前必掌握知识点

    2022-10-09 04:32:57
  • Python3+Pygame实现射击游戏完整代码

    2022-10-14 00:15:02
  • flask 实现上传图片并缩放作为头像的例子

    2021-09-08 06:32:42
  • Go中过滤范型集合性能示例详解

    2024-04-27 15:27:35
  • 【Python】Python的urllib模块、urllib2模块批量进行网页下载文件

    2021-04-26 18:19:14
  • python基础教程之序列详解

    2021-05-29 23:52:04
  • 正则表达式中两个反斜杠的匹配规则详解

    2023-10-05 17:24:37
  • 基于Python中random.sample()的替代方案

    2021-01-16 18:41:07
  • python去重,一个由dict组成的list的去重示例

    2023-09-26 03:54:44
  • asp之家 网络编程 m.aspxhome.com