ASP常用函数

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

Array()
 FUNCTION: 返回一个数组
 SYNTAX: Array(list)
 ARGUMENTS: 字符,数字均可
 EXAMPLE: <%
Dim myArray()
For i = 1 to 7
  Redim Preserve myArray(i)
  myArray(i) = WeekdayName(i)
Next
%>
 RESULT: 建立了一个包含7个元素的数组myArray
myArray("Sunday","Monday", ... ... "Saturday")
 
CInt()
 FUNCTION: 将一个表达式转化为数字类型
 SYNTAX: CInt(expression)
 ARGUMENTS: 任何有效的字符均可
 EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%>
 RESULT: 236
转化字符"234"为数字"234",如果字符串为空,则返回0值 
 
CreateObject()
 FUNCTION: 建立和返回一个已注册的ACTIVEX组件的实例。
 SYNTAX: CreateObject(objName)
 ARGUMENTS: objName 是任何一个有效、已注册的ACTIVEX组件的名字.
 EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%>
 RESULT: 
 
CStr()
 FUNCTION: 转化一个表达式为字符串.
 SYNTAX: CStr(expression)
 ARGUMENTS: expression 是任何有效的表达式。
 EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%>
 RESULT: 转化数字“5”为字符“5”。
 
Date()
 FUNCTION: 返回当前系统日期.
 SYNTAX: Date()
 ARGUMENTS: None.
 EXAMPLE: <%=Date%>
 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
%>

<%
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";
 
DateDiff()
 FUNCTION: 返回两个日期之间的差值 。
 SYNTAX: DateDiff(timeinterval,date1,date2 [, firstdayofweek ][,
firstweekofyear]])
 ARGUMENTS: timeinterval 表示相隔时间的类型,如“M“表示“月”。
 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: 从8/4/99 到2000年还有 150 天.
 
Day()
 FUNCTION: 返回一个月的第几日 .
 SYNTAX: Day(date)
 ARGUMENTS: date 是任何有效的日期。 
 EXAMPLE: <%=Day(#8/4/99#)%>
 RESULT: 4
 
FormatCurrency()
 FUNCTION: 返回表达式,此表达式已被格式化为货币值 
 SYNTAX: FormatCurrency(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
 ARGUMENTS: Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是
计算机的区域设置; LeadingDigit 三态常数,指示是否显示小数值小数点前面的
零。 
 EXAMPLE: <%=FormatCurrency(34.3456)%>
 RESULT: $34.35
 
FormatDateTime()
 FUNCTION: 返回表达式,此表达式已被格式化为日期或时间
 SYNTAX: FormatDateTime(Date, [, NamedFormat])
 ARGUMENTS: NamedFormat 指示所使用的日期/时间格式的数值,如果省略,则使用
vbGeneralDate.
 EXAMPLE: <%=FormatDateTime("08/4/99", vbLongDate)%>
 RESULT: Wednesday, August 04, 1999
 
FormatNumber()
 FUNCTION: 返回表达式,此表达式已被格式化为数值.
 SYNTAX: FormatNumber(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
 ARGUMENTS: Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是
计算机的区域设置。; LeadingDigit i指示小数点右侧显示位数的数值。默认值为 -
1,指示使用的是计算机的区域设置。; Paren 指示小数点右侧显示位数的数值。默认
值为 -1,指示使用的是计算机的区域设置。; GroupDigit i指示小数点右侧显示位数
的数值。默认值为 -1,指示使用的是计算机的区域设置。.
 EXAMPLE: <%=FormatNumber(45.324567, 3)%>
 RESULT: 45.325
 
FormatPercent()
 FUNCTION: 返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以
100 )。 (%)
 SYNTAX: FormatPercent(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
 ARGUMENTS: 同上.
 EXAMPLE: <%=FormatPercent(0.45267, 3)%>
 RESULT: 45.267%
 
Hour()
 FUNCTION: 以24时返回小时数.
 SYNTAX: Hour(time)
 ARGUMENTS: 
 EXAMPLE: <%=Hour(#4:45:34 PM#)%>
 RESULT: 16
(Hour has been converted to 24-hour system)
 
Instr()
 FUNCTION: 返回字符或字符串在另一个字符串中第一次出现的位置.
 SYNTAX: Instr([start, ] strToBeSearched, strSearchFor [, compare])
 ARGUMENTS: Start为搜索的起始值,strToBeSearched接受搜索的字符串 
strSearchFor要搜索的字符.compare比较方式(详细见ASP常数)
 EXAMPLE: <%
strText = "This is a test!!"
pos = Instr(strText, "a")
response.write pos
%>
 RESULT: 9
 
InstrRev()
 FUNCTION: 同上,只是从字符串的最后一个搜索起
 SYNTAX: InstrRev([start, ] strToBeSearched, strSearchFor [, compare])
 ARGUMENTS: 同上.
 EXAMPLE: <%
strText = "This is a test!!"
pos = InstrRev(strText, "s")
response.write pos
%>
 RESULT: 13

 
Int()
 FUNCTION: 返回数值类型,不四舍五入,注意取值是不大于它的整数。
 SYNTAX: Int(number)
 ARGUMENTS: 
 EXAMPLE: <%=INT(32.89)%>  <%=int(-3.33)%>
 RESULT: 32  -4
 
IsArray()
 FUNCTION: 判断一对象是否为数组,返回布尔值 .
 SYNTAX: IsArray(name)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "Test!"
response.write IsArray(strTest)
%>
 RESULT: False
 
IsDate()
 FUNCTION: 判断一对象是否为日期,返回布尔值
 SYNTAX: IsDate(expression)
 ARGUMENTS: expression is any valid expression.
 EXAMPLE: <%
strTest = "8/4/99"
response.write IsDate(strTest)
%>
 RESULT: True
 
IsEmpty()
 FUNCTION: 判断一对象是否初始化,返回布尔值.
 SYNTAX: IsEmpty(expression)
 ARGUMENTS: 
 EXAMPLE: <%
Dim i
response.write IsEmpty(i)
%>
 RESULT: True
 
IsNull()
 FUNCTION: 判断一对象是否为空,返回布尔值.
 SYNTAX: IsNull(expression)
 ARGUMENTS: 
 EXAMPLE: <%
Dim i
response.write IsNull(i)
%>
 RESULT: False
 
IsNumeric()
 FUNCTION: 判断一对象是否为数字,返回布尔值.
 SYNTAX: IsNumeric(expression)
 ARGUMENTS: 
 EXAMPLE: <%
i = "345"
response.write IsNumeric(i)
%>
 RESULT: True
就算数字加了引号,ASP还是认为它是数字。
 
IsObject()
 FUNCTION: 判断一对象是否为对象,返回布尔值.
 SYNTAX: IsObject(expression)
 ARGUMENTS: 
 EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)
%>
 RESULT: True
 
LBound()
 FUNCTION: 返回指定数组维的最小可用下标.
 SYNTAX: Lbound(arrayname [, dimension])
 ARGUMENTS: ; dimension 指明要返回哪一维下界的整数。使用 1 表示第一维,2
表示第二维,以此类推。如果省略 dimension 参数,默认值为 1.
 EXAMPLE: <%
i = Array("Monday","Tuesday","Wednesday")
response.write LBound(i)
%>
 RESULT: 0
 
LCase()
 FUNCTION:  返回字符串的小写形式
 SYNTAX: Lcase(string)
 ARGUMENTS: string is any valid string expression.
 EXAMPLE: <%
strTest = "This is a test!"
response.write LCase(strTest)
%>
 RESULT: this is a test!
 
Left()
 FUNCTION: 返回字符串左边第length个字符以前的字符(含第length个字符).
 SYNTAX: Left(string, length)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "This is a test!"
response.write Left(strTest, 3)
%>
 RESULT: Thi
 
Len()
 FUNCTION: 返回字符串的长度.
 SYNTAX: Len(string | varName)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "This is a test!"
response.write Len(strTest)
%>
 RESULT: 15
 
LTrim()
 FUNCTION: 去掉字符串左边的空格.
 SYNTAX: LTrim(string)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = " This is a test!"
response.write LTrim(strTest)
%>
 RESULT: This is a test!
 
Mid()
 FUNCTION: 返回特定长度的字符串(从start开始,长度为length).
 SYNTAX: Mid(string, start [, length])
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "This is a test! Today is Monday."
response.write Mid(strTest, 17, 5)
%>
 RESULT: Today
 
Minute()
 FUNCTION: 返回时间的分钏.
 SYNTAX: Minute(time)
 ARGUMENTS: 
 EXAMPLE: <%=Minute(#12:45:32 PM#)%>
 RESULT: 45
 
Month()
 FUNCTION: 返回日期.
 SYNTAX: Month(date)
 ARGUMENTS: date is any valid date expression.
 EXAMPLE: <%=Month(#08/04/99#)%>
 RESULT: 8
 
MonthName()
 FUNCTION: Returns a string identifying the specified month.
 SYNTAX: MonthName(month, [, Abb])
 ARGUMENTS: month is the numeric representation for a given month; Abb
(optional) is a boolean value used to display month abbreviation. True
will display the abbreviated month name and False (default) will not show
the abbreviation.
 EXAMPLE: <%=MonthName(Month(#08/04/99#))%>
 RESULT: August
 
Now()
 FUNCTION: Returns the current system date and time.
 SYNTAX: Now()
 ARGUMENTS: None
 EXAMPLE: <%=Now%>
 RESULT: 8/4/99 9:30:16 AM
 
Replace()
 FUNCTION: Returns a string in which a specified sub-string has been
replaced with another substring a specified number of times.
 SYNTAX: Replace(strToBeSearched, strSearchFor, strReplaceWith [, start
][, count ][, compare]]])
 ARGUMENTS: strToBeSearched is a string expression containing a sub-
string to be replaced; strSearchFor is the string expression to search for
within strToBeSearched; strReplaceWith is the string expression to replace
sub-string strSearchFor; start (optional) is the numeric character
position to begin search; count (optional) is a value indicating the
comparision constant.
 EXAMPLE: <%
strTest = "This is an apple!"
response.write Replace(strTest, "apple", "orange")
%>
 RESULT: This is an orange!
 
Right()
 FUNCTION: 返回字符串右边第length个字符以前的字符(含第length个字符).
 SYNTAX: Right(string, length)
 ARGUMENTS: .
 EXAMPLE: <%
strTest = "This is an test!"
response.write Right(strTest, 3)
%>
 RESULT: st!
 
Rnd()
 FUNCTION: 产生一个随机数.
 SYNTAX: Rnd [ (number) ]
 ARGUMENTS: 
 EXAMPLE: <%
Randomize()
response.write RND()
%>
 RESULT: 任何一个在0 到 1 之间的数
 
Round()
 FUNCTION: 返回按指定位数进行四舍五入的数值.
 SYNTAX: Round(expression [, numRight])
 ARGUMENTS: numRight数字表明小数点右边有多少位进行四舍五入。如果省略,则
Round 函数返回整数.
 EXAMPLE: <%
i = 32.45678
response.write Round(i)
%>
 RESULT: 32
 
Rtrim()
 FUNCTION: 去掉字符串右边的字符串.
 SYNTAX: Rtrim(string)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "This is a test!! "
response.write RTrim(strTest)
%>
 RESULT: This is a test!!
 
Second()
 FUNCTION: 返回秒.
 SYNTAX: Second(time)
 ARGUMENTS: .
 EXAMPLE: <%=Second(#12:34:28 PM#)%>
 RESULT: 28
 
StrReverse()
 FUNCTION: 反排一字符串
 SYNTAX: StrReverse(string)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "This is a test!!"
response.write StrReverse(strTest)
%>
 RESULT: !!tset a si sihT
 
Time()
 FUNCTION: 返回系统时间.
 SYNTAX: Time()
 ARGUMENTS: .
 EXAMPLE: <%=Time%>
 RESULT: 9:58:28 AM
 
Trim()
 FUNCTION: 去掉字符串左右的空格.
 SYNTAX: Trim(string)
 ARGUMENTS: string is any valid string expression.
 EXAMPLE: <%
strTest = " This is a test!! "
response.write Trim(strTest)
%>
 RESULT: This is a test!!
 
UBound()
 FUNCTION: 返回指定数组维数的最大可用下标.
 SYNTAX: Ubound(arrayname [, dimension])
 ARGUMENTS: ; dimension (optional) 指定返回哪一维上界的整数。1 表示第一
维,2 表示第二维,以此类推。如果省略 dimension 参数,则默认值为 1.
 EXAMPLE: <%
i = Array("Monday","Tuesday","Wednesday")
response.write UBound(i)
%>
 RESULT: 2
 
UCase()
 FUNCTION: 返回字符串的大写形式.
 SYNTAX: UCase(string)
 ARGUMENTS: 
 EXAMPLE: <%
strTest = "This is a test!!"
response.write UCase(strTest)
%>
 RESULT: THIS IS A TEST!!
 
VarType()
 FUNCTION: 返回指示变量子类型的值
 SYNTAX: VarType(varName)
 ARGUMENTS: 
 EXAMPLE: <%
i = 3
response.write varType(i)
%>
 RESULT: 2(数字)详见"asp常数"
 
WeekDay()
 FUNCTION: 返回在一周的第几天.
 SYNTAX: WeekDay(date [, firstdayofweek])
 ARGUMENTS: .
 EXAMPLE: <%
d = #8/4/99#
response.write Weekday(d)
%>
 RESULT: 4(星期三)
 
WeekDayName()
 FUNCTION: 返回一周第几天的名字.
 SYNTAX: WeekDayName(weekday [, Abb ][, firstdayofweek]])
 ARGUMENTS: Abb可选。Boolean 值,指明是否缩写表示星期各天的名称。如果省
略, 默认值为 False,即不缩写星期各天的名称.firstdayofweek指明星期第一天的
数值
 EXAMPLE: <%
d = #8/4/99#
response.write WeekdayName(Weekday(d))
%>
 RESULT: Wednesday
 
Year()
 FUNCTION: 返回当前的年份.
 SYNTAX: Year(date)
 ARGUMENTS: 
 EXAMPLE: <%=Year(#8/4/99#)%>
 RESULT: 1999
 

asp常用函数大全 学习asp必备 asp常用函数大全 学习asp 制作asp网站必备。 立即下载

相关推荐

asp常用函数集合

asp常用函数集合

asp常用函数

asp常用函数     Array()  FUNCTION: 返回一个数组  SYNTAX: Array(list)  ARGUMENTS: 字符,数字均可  EXAMPLE: Dim myArray()For i = 1 to 7  Redim Preserve myArray(i)  myArray(i) = WeekdayName(i)Next%>  RESULT: 建立了一个包含7个元素的

okook的专栏 826

ASP函数大全(很全面)

ASP函数大全 ASP函数大全 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 

ASP页面function的写法即使用

最近做了一个网站 - 渝酒坊(http://www.wine22.com),由于预算有限,使用的是asp空间。之前写asp都是随心所欲,这次想学学封装。使用Function来完成。 写一个aspfunctionfunction test (name) response.write("你的名字是:"&name) end function 调用: test("渝酒坊")

蝶园 1万+

asp 常用函数大全

asp 常用函数大全  

565

ASP VBSCRIPT常用函数

 函数,就是该语言封装了的一个功能块,以方便用户的调用。比如“now()”在VBScript中就是一个能显示出当前日期和时间的函数。至于具体为什么能显示,则是该语言内核所定的,用户只需明白“now()”就是用来能显示日期时间的。那么,我们当前接触的VBScript还有其他什么功能的函数么?  1,日期/时间函数  这些函数包括对“年”、“月”、“日”、“时”、“分”、“秒”、“星期”等的显

【小妮的天空】 866

ASP常用的几个功能模块封装成函数调用(登录验证,状态切换。。) http://www.tsingfeng.com/archives/?article-89.html

1,经常写些系统,那么一般都是从登录程序开始,每接一个系统就写一次登录,好麻烦。 干脆直接做个登录验证函数吧,对我来说,大都情况可以胜任了:) Function chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl) dim cn_name,cn_pwd cn_name=trim(request.form(""&a

xu的blog 1628

ASP常用函数

ASP常用函数,希望能用的着。 dim db db="dbms.mdb" ****************************************************************** 执行sql语句,不返回值,sql语句最好是如下: update 表名 set 字段名=value,字段名=value where 字段名=value delete from 表名 w

BineonBlog 2387

asp.net常用函数

asp.net常用函数 asp.net常用函数Abs(number) 取得数值的绝对值。   Asc(String) 取得字符串表达式的第一个字符ASCII 码。   Atn(number) 取得一个角度的反正切值。   CallByName (object, procname, usecalltype,[args()]) 执行一个对象的方法、设定或传回对象的属性。   CBool(expre

Pinocchio 的专栏 755

Asp.Net常用函数

Asp.Net常用函数 Abs(number) 取得数值的绝对值。   Asc(String) 取得字符串表达式的第一个字符ASCII 码。   Atn(number) 取得一个角度的反正切值。   CallByName (object, procname, usecalltype,[args()]) 执行一个对象的方法、设定或传回对象的属性。   CBool(expression) 转换表达式为

lalaguy的专栏 709

常用ASP内置函数,ASP内置函数

ASP常用函数 Array()函数返回一个数组表达式 Array(list) 你我一起舞共续ASP经典辉煌!--POWERED BY 25175允许数据类型: 字符,数字均可实例: <%Dim myArray()For i = 1 to 7Redim Preserve myArray(i)myArray(i) = WeekdayName(i)Next%>返回结果:...

230

asp 常用函数用法

Array()     FUNCTION: 返回一个数组     SYNTAX: Array(list)     ARGUMENTS: 字符,数字均可     EXAMPLE: <%     Dim myArray()     For i = 1 to 7     Redim Preserve myArray(i)     myArray(i) = WeekdayName(i)     Next     %>     RESULT: 建立了一个包含7个元素的数组myArray     myArray(“Sunday”,”Monday”, … … “Saturday”)  CInt()     

我写ASP常用到的一些函数

对于ASP语言来说,把某一功能模块写成类,那对于效率来讲,未必是件很提倡的事,但是把这种模块化向小了去说,把一些功能写成函数,那就对于在ASP开发的时候,省不少事了,以下是一些我经常用到的函数,有一些是我写的,有的是从网上找的,比如说CFS编码的;网上的CFS编码的函数里面的变量都没声明,所以在我的页面声明了option explicit后就不能正常使用了,很简单,我在FUNCTION里把变量声明

欢迎访问http://3rgb.com 2060
下一篇: ddfd
ditn
博客等级 码龄21年 0粉丝 4原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值