今天是:
 
现在位置:首页->文章频道->技术资料
ASP 系列函数大全
时间:2007-11-29 10:08:57 来源: 作者: 编辑:admin 【关闭】浏览:

CStr() 
 
函数转化一个表达式为字符串. 
 
表达式 CStr(expression) 
 
允许数据类型: expression 是任何有效的表达式。 
 
实例: <% 
 
s = 3 + 2 
 
response.write "The 返回结果 is: " & cStr(s) 
 
%> 
 
返回结果: 转化数字“5”为字符“5”。 
 
 
Date() 
 
函数返回当前系统日期. 
 
表达式 Date() 
 
允许数据类型: None. 
 
实例: <%=Date%> 
 
返回结果: 9/9/00 
 
 
DateAdd() 
 
函数返回一个被改变了的日期。 
 
表达式 DateAdd(timeinterval,number,date) 
 
允许数据类型: 
timeinterval is the time interval to add; 
number is amount of time intervals to add; 
and date is the starting date. 
 
实例: <% 
 
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/00 
 
3:34:45 PM 
 
"m" = "month"; 
 
"d" = "day"; 
 
If currentDate is in time format then, 
 
"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 
 
 
FormatDateTime() 
 
函数返回表达式,此表达式已被格式化为日期或时间 
 
表达式 FormatDateTime(Date, [, NamedFormat]) 
 
允许数据类型: NamedFormat 指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate. 
 
实例: <%=FormatDateTime("09/9/00", vbLongDate)%> 
 
返回结果: Sunday, September 09, 2000 
 
 
FormatNumber() 
 
函数返回表达式,此表达式已被格式化为数值. 
 
表达式 FormatNumber(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]]) 
 
允许数据类型: Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; LeadingDigit i指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; Paren 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; GroupDigit i指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。. 
 
实例: <%=FormatNumber(45.324567, 3)%> 
 
返回结果: 45.325 
 
 
FormatPercent() 
 
函数返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以 100 )。 (%) 
 
表达式 FormatPercent(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]]) 
 
允许数据类型: 同上. 
 
实例: <%=FormatPercent(0.45267, 3)%> 
 
返回结果: 45.267% 
 
 
Hour() 
 
函数以24时返回小时数. 
 
表达式 Hour(time) 
 
允许数据类型: 
 
实例: <%=Hour(#4:45:34 PM#)%> 
 
返回结果: 16 
 
(Hour has been converted to 24-hour system) 
 
 
Instr() 
 
函数返回字符或字符串在另一个字符串中第一次出现的位置. 
 
表达式 Instr([start, ] strToBeSearched, strSearchFor [, compare]) 
 
允许数据类型: Start为搜索的起始值,strToBeSearched接受搜索的字符串 strSearchFor要搜索的字符.compare比较方式(详细见ASP常数) 
 
实例: <% 
 
strText = "This is a test!!" 
 
pos = Instr(strText, "a") 
 
response.write pos 
 
%> 
 
返回结果: 9 
 
 
InstrRev() 
 
函数同上,只是从字符串的最后一个搜索起 
 
表达式 InstrRev([start, ] strToBeSearched, strSearchFor [, compare]) 
 
允许数据类型: 同上. 
 
实例: <% 
 
strText = "This is a test!!" 
 
pos = InstrRev(strText, "s") 
 
response.write pos 
 
%> 
 
返回结果: 13 
 
 
 
Int() 
 
函数返回数值类型,不四舍五入。 
 
表达式 Int(number) 
 
允许数据类型: 
 
实例: <%=INT(32.89)%> 
 
返回结果: 32 
 
 
IsArray() 
 
函数判断一对象是否为数组,返回布尔值 . 
 
表达式 IsArray(name) 
 
实例: <% 
 
strTest = "Test!" 
 
response.write IsArray(strTest) 
 
%> 
 
返回结果: False 
 
 

推荐精彩图片
信息评论
您要为您所发的言论的后果负责,故请各位遵纪守法并注意语言文明。
查看评论
匿名
验证码:
标 题:
*
留 言:
*
新闻搜索
标题:
相关文章
招商信息
弈飞网站内容管理系统!VSFLYCMSV1.0 AC2 正式版
VsFly.Com All Rights Reserved 版权所有
未经授权禁止用于商业行为