ASP下經(jīng)常用的字符串等函數(shù)參考資料
更新時(shí)間:2007年11月22日 22:47:03 作者:
參考資料之ASP函數(shù) 整理下asp下常用的字符串,數(shù)據(jù)等操作函數(shù),大家在平時(shí)操作中也經(jīng)常遇到的
1.函數(shù) array()
功能:創(chuàng)建一個(gè)數(shù)組變量
格式:array(list)
參數(shù):list 為數(shù)組變量中的每個(gè)數(shù)值列,中間用逗號(hào)間隔
例子:
結(jié)果: i 被賦予為數(shù)組
2.函數(shù) Cint()
功能:將一表達(dá)式/其它類型的變量轉(zhuǎn)換成整數(shù)類型(int)
格式:Cint(expression)
參數(shù):expression 是任何有效的表達(dá)式/其它類型的變量
例子:
結(jié)果: 236
函數(shù)Cint()將字符"234"轉(zhuǎn)換 成整數(shù)234.如果表達(dá)式為空, 或者無效時(shí),返回值為0;
3.函數(shù): Creatobject()
功能:創(chuàng)建及返回一個(gè)ActiveX對(duì)象.
格式:Creatobject(obname)
參數(shù):obname 是對(duì)象的名稱
例子:
結(jié)果:
4.函數(shù) Cstr()
功能:將一表達(dá)式/其它類型的變量轉(zhuǎn)換成字符類型(string)
格式:Cstr(expression)
參數(shù):expression是任何有效的表達(dá)式/其它類型的變量
例子:
結(jié)果:函數(shù)Cstr()將整數(shù) 5 轉(zhuǎn)換 成字符"5".
5.函數(shù) Date()
功能:返回當(dāng)前系統(tǒng)(server端)的日期
格式:Date()
參數(shù):無
例子:
結(jié)果:05/10/00
6.函數(shù) Dateadd()
功能:計(jì)算某個(gè)指定的時(shí)間和
格式:dateadd(timeinterval,number,date)
參數(shù):timeinterval是時(shí)間單位(月,日..); number是時(shí)間間隔值,date是時(shí)間始點(diǎn).
例子:
結(jié)果:
11/4/99
3:34:45 PM
其中
"m" = "month";
"d" = "day";
如果是currentDate 格式,則,
"h" = "hour";
"s" = "second";
7.函數(shù) Datediff()
功能:計(jì)算某量個(gè)指定的時(shí)間差
格式:datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]])
參數(shù):timeinterval 是時(shí)間單位; date1,date2是有效的日期表達(dá)式,firstdayofweek,firstdayofyear 是任意選項(xiàng).
例子:
結(jié)果:There are 150 days to millenium from 8/4/99.
8.函數(shù) day()
功能:返回一個(gè)整數(shù)值,對(duì)應(yīng)于某月的某日
格式:day(date)
參數(shù):date是一個(gè)有效的日期表達(dá)式;
例子:
結(jié)果:4
9.函數(shù) formatcurrency()
功能:轉(zhuǎn)換成貨幣格式
格式:formatcurrency(expression [,digit[,leadingdigit[,paren[,groupdigit]]]])
參數(shù):expression 是有效的數(shù)字表達(dá)式;digit表示小數(shù)點(diǎn)后的位數(shù);leadingdigit,paren,groupdigit是任意選項(xiàng).
例子:
結(jié)果:$34.35
10.函數(shù) Formatdatetime()
功能:格式化日期表達(dá)式/變量
格式:formatdatetime(date[,nameformat])
參數(shù):date為有效的日期表達(dá)式/變量;nameformat是指定的日期格式常量名稱.
例子:
結(jié)果:Wednesday,August 04,1999
11.函數(shù) formatnumber()
功能:格式化數(shù)字表達(dá)式/變量
格式:formatnumbe(expression [,digit[,leadingdigit[,paren[,groupdigit]]]])
參數(shù):express為有效的數(shù)字表達(dá)式, digit表示小數(shù)點(diǎn)后的位數(shù);leadingdigit,paren,groupdigit是任意選項(xiàng)
例子:
結(jié)果: 23.222
12.函數(shù) formatpercent()
功能:格式化百分?jǐn)?shù)表達(dá)式/變量
格式:formatnumber(expression [,digit [,leading [,paren[,groupdigit]]]])
參數(shù):expression 是有效的數(shù)字表達(dá)式,digit表示小數(shù)點(diǎn)后的位數(shù);leadingdigit,paren,groupdigit是任意選項(xiàng)
例子:
結(jié)果: 45.233
13.函數(shù): hour()
功能:返回一個(gè)數(shù)值,對(duì)應(yīng)于的指定時(shí)間.
格式:hour(time)
參數(shù):time對(duì)應(yīng)于的指定時(shí)間.
例子:
結(jié)果:16 (24 小時(shí)制)
14.函數(shù) instr()
功能:返回一個(gè)數(shù)值,對(duì)應(yīng)于某字符(串)在另一字符串中的位置.
格式:instr([start,]strtobesearched,strsearchfor [,compare])
參數(shù):start(任選)是從第start位尋找,strtobesearched 是被搜索的字符串,strsearchfor是被尋找的目標(biāo).compare是任意選項(xiàng)
例子:
結(jié)果:9,(字符"a"在strtext字符串的第九位)
15.函數(shù) instrrev()
功能:返回一個(gè)數(shù)值,對(duì)應(yīng)于某字符(串)在另一字符串中的位置(從后面起開始尋找).
格式:instrrev([start,] strtobesearched,strsearchfor[,compare])
參數(shù):參考 instr(),
例子:
結(jié)果:13, 字串"s"是strtext的第13個(gè)字符(從后面起開始尋找)
16.函數(shù) int()
功能:數(shù)字取整
格式:int(number)
參數(shù):number 是任何有效的數(shù)字表達(dá)式/其它類型的變量
例子:
結(jié)果:322 (如果用Cint()則結(jié)果是323)
17.函數(shù) isarray()
功能:返回一個(gè)布爾值,判斷變量是否為數(shù)組.
格式: isarray(name)
參數(shù):name是變量名稱
例子:
結(jié)果:false
18.函數(shù) isdate()
功能:返回一個(gè)布爾值,判斷變量是否為日期變量.
格式:isdate(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果:true
19.函數(shù) isempty()
功能:返回一個(gè)布爾值,判斷變量是否為空.
格式:isempty(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果:true
20.函數(shù) isnull()
功能:返回一個(gè)布爾值,判斷變量是否包含非法的數(shù)據(jù).
格式:isnull(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果:false
21.函數(shù) Isnumeric()
功能:返回一個(gè)布爾值,判斷變量是否為數(shù)字變量,或者是可以轉(zhuǎn)換成數(shù)字的其它變量.
格式:isnumeric(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果: true.
22.函數(shù) Isobject()
功能:返回一個(gè)布爾值,判斷變量是否為對(duì)象的變量,
格式:isobject(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果: true
23.函數(shù): Lbound()
功能:返回一個(gè)數(shù)組的下界.
格式:Lbound(arrayname[,dimension])
參數(shù):arrayname 是數(shù)組變量,dimension 是任意項(xiàng)
例子:
結(jié)果:0
24.函數(shù) Lcase()
功能:將一字符類型變量的字符全部變換小寫字符.
格式:Lcase(string)
參數(shù):string是字串變量
例子:
結(jié)果:this is lcase!
25.函數(shù) left()
功能:截取一個(gè)字符串的前部分;
格式:left(string,length)
參數(shù):string字符串,length截取的長度.
例子:
結(jié)果:this i
26.函數(shù) len()
功能:返回字符串長度或者變量的字節(jié)長度
格式:len(string |varname)
參數(shù):string字符串;varname任意的變量名稱
例子:
結(jié)果:15
27.函數(shù) ltrim()
功能:去掉字符串前的空格.
格式:ltrim(string)
參數(shù):string 字串.
例子:
結(jié)果:Today
29.函數(shù) minute()
功能:返回一數(shù)值, 表示分鐘
格式:minute(time)
參數(shù): time是時(shí)間變量
例子:
結(jié)果:23
30.函數(shù) month()
功能:返回一數(shù)值, 表示月份
格式:month(time)
參數(shù):time是日期變量
例子:
結(jié)果:9
31.函數(shù) monthname()
功能:返回月份的字符串(名稱).
格式:Monthname(date [,abb])
參數(shù):date是日期變量,abb=true時(shí) 則月份的縮寫,
例子:
結(jié)果:April
32.函數(shù) Now()
功能:返回系統(tǒng)的當(dāng)前時(shí)間和日期.
格式:now()
參數(shù):無
例子:
結(jié)果: 05/10/00 8:45:32 pm
33.函數(shù): replace()
功能:在字串中查找,替代指定的字串.
格式:replace(strtobesearched,strsearchfor,strreplacewith
[,start[,count[,compare]]])
參數(shù):strtobesearched是字串; strsearchfor是被查找的子字串;strreplacewith
是用來替代的子字串.start,count,compare 是任意選項(xiàng).
例子:
結(jié)果:this is an orange.
34.函數(shù) right()
功能:截取一個(gè)字符串的后部分
格式:right(string,length)
參數(shù):string字符串,length截取的長度.
例子:
結(jié)果:st!
35.函數(shù) rnd()
功能:返回一個(gè)隨機(jī)數(shù)值
格式:rnd[(number)]
參數(shù):number是任意數(shù)值.
例子:
結(jié)果:0/1數(shù)值之一,無randomize(), 則不能產(chǎn)生隨機(jī)數(shù).
36.函數(shù)round()
功能:完整數(shù)值
格式:round(expression[,numright])
參數(shù):expression數(shù)字表達(dá)式;numright任意選項(xiàng).
例子:
結(jié)果: 12
37.函數(shù) rtrim()
功能:去掉字符串后的空格.
格式:rtrim(string)
參數(shù):string 是字串
例子:
結(jié)果:this is a test!
38.函數(shù) second()
功能:返回一個(gè)整數(shù)值.
格式:second(time)
參數(shù):time是一個(gè)有效的時(shí)間表達(dá)式;
例子:
結(jié)果:30
39.函數(shù) strReverse()
功能:返回與原字串排列逆向的字串.
格式:strreverse(string)
參數(shù):string是字串
例子:
--------------------------------------------------------------------------------
下面為帶例子的:
Array()
FUNCTION: 返回一個(gè)數(shù)組
SYNTAX: Array(list)
ARGUMENTS: 字符,數(shù)字均可
EXAMPLE: <%
Dim myArray()
For i = 1 to 7
Redim Preserve myArray(i)
myArray(i) = WeekdayName(i)
Next
%>
RESULT: 建立了一個(gè)包含7個(gè)元素的數(shù)組myArray
myArray("Sunday","Monday", ... ... "Saturday")
CInt()
FUNCTION: 將一個(gè)表達(dá)式轉(zhuǎn)化為數(shù)字類型
SYNTAX: CInt(expression)
ARGUMENTS: 任何有效的字符均可
EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%>
RESULT: 236
轉(zhuǎn)化字符"234"為數(shù)字"234",如果字符串為空,則返回0值
CreateObject()
FUNCTION: 建立和返回一個(gè)已注冊的ACTIVEX組件的實(shí)例。
SYNTAX: CreateObject(objName)
ARGUMENTS: objName 是任何一個(gè)有效、已注冊的ACTIVEX組件的名字.
EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%>
RESULT:
CStr()
FUNCTION: 轉(zhuǎn)化一個(gè)表達(dá)式為字符串.
SYNTAX: CStr(expression)
ARGUMENTS: expression 是任何有效的表達(dá)式。
EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%>
RESULT: 轉(zhuǎn)化數(shù)字“5”為字符“5”。
Date()
FUNCTION: 返回當(dāng)前系統(tǒng)日期.
SYNTAX: Date()
ARGUMENTS: None.
EXAMPLE: <%=Date%>
RESULT: 8/4/99
DateAdd()
FUNCTION: 返回一個(gè)被改變了的日期。
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: 返回兩個(gè)日期之間的差值 。
SYNTAX: DateDiff(timeinterval,date1,date2 [, firstdayofweek ][,
firstweekofyear]])
ARGUMENTS: timeinterval 表示相隔時(shí)間的類型,如“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: 返回一個(gè)月的第幾日 .
SYNTAX: Day(date)
ARGUMENTS: date 是任何有效的日期。
EXAMPLE: <%=Day(#8/4/99#)%>
RESULT: 4
FormatCurrency()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為貨幣值
SYNTAX: FormatCurrency(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
ARGUMENTS: Digit 指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)值為 -1,指示使用的是
計(jì)算機(jī)的區(qū)域設(shè)置; LeadingDigit 三態(tài)常數(shù),指示是否顯示小數(shù)值小數(shù)點(diǎn)前面的
零。
EXAMPLE: <%=FormatCurrency(34.3456)%>
RESULT: $34.35
FormatDateTime()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為日期或時(shí)間
SYNTAX: FormatDateTime(Date, [, NamedFormat])
ARGUMENTS: NamedFormat 指示所使用的日期/時(shí)間格式的數(shù)值,如果省略,則使用
vbGeneralDate.
EXAMPLE: <%=FormatDateTime("08/4/99", vbLongDate)%>
RESULT: Wednesday, August 04, 1999
FormatNumber()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為數(shù)值.
SYNTAX: FormatNumber(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
ARGUMENTS: Digit 指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)值為 -1,指示使用的是
計(jì)算機(jī)的區(qū)域設(shè)置。; LeadingDigit i指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)值為 -
1,指示使用的是計(jì)算機(jī)的區(qū)域設(shè)置。; Paren 指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)
值為 -1,指示使用的是計(jì)算機(jī)的區(qū)域設(shè)置。; GroupDigit i指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)
的數(shù)值。默認(rèn)值為 -1,指示使用的是計(jì)算機(jī)的區(qū)域設(shè)置。.
EXAMPLE: <%=FormatNumber(45.324567, 3)%>
RESULT: 45.325
FormatPercent()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為尾隨有 % 符號(hào)的百分比(乘以
100 )。 (%)
SYNTAX: FormatPercent(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
ARGUMENTS: 同上.
EXAMPLE: <%=FormatPercent(0.45267, 3)%>
RESULT: 45.267%
Hour()
FUNCTION: 以24時(shí)返回小時(shí)數(shù).
SYNTAX: Hour(time)
ARGUMENTS:
EXAMPLE: <%=Hour(#4:45:34 PM#)%>
RESULT: 16
(Hour has been converted to 24-hour system)
Instr()
FUNCTION: 返回字符或字符串在另一個(gè)字符串中第一次出現(xiàn)的位置.
SYNTAX: Instr([start, ] strToBeSearched, strSearchFor [, compare])
ARGUMENTS: Start為搜索的起始值,strToBeSearched接受搜索的字符串
strSearchFor要搜索的字符.compare比較方式(詳細(xì)見ASP常數(shù))
EXAMPLE: <%
strText = "This is a test!!"
pos = Instr(strText, "a")
response.write pos
%>
RESULT: 9
InstrRev()
FUNCTION: 同上,只是從字符串的最后一個(gè)搜索起
SYNTAX: InstrRev([start, ] strToBeSearched, strSearchFor [, compare])
ARGUMENTS: 同上.
EXAMPLE: <%
strText = "This is a test!!"
pos = InstrRev(strText, "s")
response.write pos
%>
RESULT: 13
Int()
FUNCTION: 返回?cái)?shù)值類型,不四舍五入,注意取值是不大于它的整數(shù)。
SYNTAX: Int(number)
ARGUMENTS:
EXAMPLE: <%=INT(32.89)%> <%=int(-3.33)%>
RESULT: 32 -4
IsArray()
FUNCTION: 判斷一對(duì)象是否為數(shù)組,返回布爾值 .
SYNTAX: IsArray(name)
ARGUMENTS:
EXAMPLE: <%
strTest = "Test!"
response.write IsArray(strTest)
%>
RESULT: False
IsDate()
FUNCTION: 判斷一對(duì)象是否為日期,返回布爾值
SYNTAX: IsDate(expression)
ARGUMENTS: expression is any valid expression.
EXAMPLE: <%
strTest = "8/4/99"
response.write IsDate(strTest)
%>
RESULT: True
IsEmpty()
FUNCTION: 判斷一對(duì)象是否初始化,返回布爾值.
SYNTAX: IsEmpty(expression)
ARGUMENTS:
EXAMPLE: <%
Dim i
response.write IsEmpty(i)
%>
RESULT: True
IsNull()
FUNCTION: 判斷一對(duì)象是否為空,返回布爾值.
SYNTAX: IsNull(expression)
ARGUMENTS:
EXAMPLE: <%
Dim i
response.write IsNull(i)
%>
RESULT: False
IsNumeric()
FUNCTION: 判斷一對(duì)象是否為數(shù)字,返回布爾值.
SYNTAX: IsNumeric(expression)
ARGUMENTS:
EXAMPLE: <%
i = "345"
response.write IsNumeric(i)
%>
RESULT: True
就算數(shù)字加了引號(hào),ASP還是認(rèn)為它是數(shù)字。
IsObject()
FUNCTION: 判斷一對(duì)象是否為對(duì)象,返回布爾值.
SYNTAX: IsObject(expression)
ARGUMENTS:
EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)
%>
RESULT: True
LBound()
FUNCTION: 返回指定數(shù)組維的最小可用下標(biāo).
SYNTAX: Lbound(arrayname [, dimension])
ARGUMENTS: ; dimension 指明要返回哪一維下界的整數(shù)。使用 1 表示第一維,2
表示第二維,以此類推。如果省略 dimension 參數(shù),默認(rèn)值為 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個(gè)字符以前的字符(含第length個(gè)字符).
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: 返回時(shí)間的分釧.
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個(gè)字符以前的字符(含第length個(gè)字符).
SYNTAX: Right(string, length)
ARGUMENTS: .
EXAMPLE: <%
strTest = "This is an test!"
response.write Right(strTest, 3)
%>
RESULT: st!
Rnd()
FUNCTION: 產(chǎn)生一個(gè)隨機(jī)數(shù).
SYNTAX: Rnd [ (number) ]
ARGUMENTS:
EXAMPLE: <%
Randomize()
response.write RND()
%>
RESULT: 任何一個(gè)在0 到 1 之間的數(shù)
Round()
FUNCTION: 返回按指定位數(shù)進(jìn)行四舍五入的數(shù)值.
SYNTAX: Round(expression [, numRight])
ARGUMENTS: numRight數(shù)字表明小數(shù)點(diǎn)右邊有多少位進(jìn)行四舍五入。如果省略,則
Round 函數(shù)返回整數(shù).
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: 返回系統(tǒng)時(shí)間.
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: 返回指定數(shù)組維數(shù)的最大可用下標(biāo).
SYNTAX: Ubound(arrayname [, dimension])
ARGUMENTS: ; dimension (optional) 指定返回哪一維上界的整數(shù)。1 表示第一
維,2 表示第二維,以此類推。如果省略 dimension 參數(shù),則默認(rèn)值為 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(數(shù)字)詳見"asp常數(shù)"
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 值,指明是否縮寫表示星期各天的名稱。如果省
略, 默認(rèn)值為 False,即不縮寫星期各天的名稱.firstdayofweek指明星期第一天的
數(shù)值
EXAMPLE: <%
d = #8/4/99#
response.write WeekdayName(Weekday(d))
%>
RESULT: Wednesday
Year()
FUNCTION: 返回當(dāng)前的年份.
SYNTAX: Year(date)
ARGUMENTS:
EXAMPLE: <%=Year(#8/4/99#)%>
RESULT: 1999
1.函數(shù) array()
功能:創(chuàng)建一個(gè)數(shù)組變量
格式:array(list)
參數(shù):list 為數(shù)組變量中的每個(gè)數(shù)值列,中間用逗號(hào)間隔
例子:
結(jié)果: i 被賦予為數(shù)組
2.函數(shù) Cint()
功能:將一表達(dá)式/其它類型的變量轉(zhuǎn)換成整數(shù)類型(int)
格式:Cint(expression)
參數(shù):expression 是任何有效的表達(dá)式/其它類型的變量
例子:
結(jié)果: 236
函數(shù)Cint()將字符"234"轉(zhuǎn)換 成整數(shù)234.如果表達(dá)式為空, 或者無效時(shí),返回值為0;
3.函數(shù): Creatobject()
功能:創(chuàng)建及返回一個(gè)ActiveX對(duì)象.
格式:Creatobject(obname)
參數(shù):obname 是對(duì)象的名稱
例子:
結(jié)果:
4.函數(shù) Cstr()
功能:將一表達(dá)式/其它類型的變量轉(zhuǎn)換成字符類型(string)
格式:Cstr(expression)
參數(shù):expression是任何有效的表達(dá)式/其它類型的變量
例子:
結(jié)果:函數(shù)Cstr()將整數(shù) 5 轉(zhuǎn)換 成字符"5".
5.函數(shù) Date()
功能:返回當(dāng)前系統(tǒng)(server端)的日期
格式:Date()
參數(shù):無
例子:
結(jié)果:05/10/00
6.函數(shù) Dateadd()
功能:計(jì)算某個(gè)指定的時(shí)間和
格式:dateadd(timeinterval,number,date)
參數(shù):timeinterval是時(shí)間單位(月,日..); number是時(shí)間間隔值,date是時(shí)間始點(diǎn).
例子:
結(jié)果:
11/4/99
3:34:45 PM
其中
"m" = "month";
"d" = "day";
如果是currentDate 格式,則,
"h" = "hour";
"s" = "second";
7.函數(shù) Datediff()
功能:計(jì)算某量個(gè)指定的時(shí)間差
格式:datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]])
參數(shù):timeinterval 是時(shí)間單位; date1,date2是有效的日期表達(dá)式,firstdayofweek,firstdayofyear 是任意選項(xiàng).
例子:
結(jié)果:There are 150 days to millenium from 8/4/99.
8.函數(shù) day()
功能:返回一個(gè)整數(shù)值,對(duì)應(yīng)于某月的某日
格式:day(date)
參數(shù):date是一個(gè)有效的日期表達(dá)式;
例子:
結(jié)果:4
9.函數(shù) formatcurrency()
功能:轉(zhuǎn)換成貨幣格式
格式:formatcurrency(expression [,digit[,leadingdigit[,paren[,groupdigit]]]])
參數(shù):expression 是有效的數(shù)字表達(dá)式;digit表示小數(shù)點(diǎn)后的位數(shù);leadingdigit,paren,groupdigit是任意選項(xiàng).
例子:
結(jié)果:$34.35
10.函數(shù) Formatdatetime()
功能:格式化日期表達(dá)式/變量
格式:formatdatetime(date[,nameformat])
參數(shù):date為有效的日期表達(dá)式/變量;nameformat是指定的日期格式常量名稱.
例子:
結(jié)果:Wednesday,August 04,1999
11.函數(shù) formatnumber()
功能:格式化數(shù)字表達(dá)式/變量
格式:formatnumbe(expression [,digit[,leadingdigit[,paren[,groupdigit]]]])
參數(shù):express為有效的數(shù)字表達(dá)式, digit表示小數(shù)點(diǎn)后的位數(shù);leadingdigit,paren,groupdigit是任意選項(xiàng)
例子:
結(jié)果: 23.222
12.函數(shù) formatpercent()
功能:格式化百分?jǐn)?shù)表達(dá)式/變量
格式:formatnumber(expression [,digit [,leading [,paren[,groupdigit]]]])
參數(shù):expression 是有效的數(shù)字表達(dá)式,digit表示小數(shù)點(diǎn)后的位數(shù);leadingdigit,paren,groupdigit是任意選項(xiàng)
例子:
結(jié)果: 45.233
13.函數(shù): hour()
功能:返回一個(gè)數(shù)值,對(duì)應(yīng)于的指定時(shí)間.
格式:hour(time)
參數(shù):time對(duì)應(yīng)于的指定時(shí)間.
例子:
結(jié)果:16 (24 小時(shí)制)
14.函數(shù) instr()
功能:返回一個(gè)數(shù)值,對(duì)應(yīng)于某字符(串)在另一字符串中的位置.
格式:instr([start,]strtobesearched,strsearchfor [,compare])
參數(shù):start(任選)是從第start位尋找,strtobesearched 是被搜索的字符串,strsearchfor是被尋找的目標(biāo).compare是任意選項(xiàng)
例子:
結(jié)果:9,(字符"a"在strtext字符串的第九位)
15.函數(shù) instrrev()
功能:返回一個(gè)數(shù)值,對(duì)應(yīng)于某字符(串)在另一字符串中的位置(從后面起開始尋找).
格式:instrrev([start,] strtobesearched,strsearchfor[,compare])
參數(shù):參考 instr(),
例子:
結(jié)果:13, 字串"s"是strtext的第13個(gè)字符(從后面起開始尋找)
16.函數(shù) int()
功能:數(shù)字取整
格式:int(number)
參數(shù):number 是任何有效的數(shù)字表達(dá)式/其它類型的變量
例子:
結(jié)果:322 (如果用Cint()則結(jié)果是323)
17.函數(shù) isarray()
功能:返回一個(gè)布爾值,判斷變量是否為數(shù)組.
格式: isarray(name)
參數(shù):name是變量名稱
例子:
結(jié)果:false
18.函數(shù) isdate()
功能:返回一個(gè)布爾值,判斷變量是否為日期變量.
格式:isdate(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果:true
19.函數(shù) isempty()
功能:返回一個(gè)布爾值,判斷變量是否為空.
格式:isempty(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果:true
20.函數(shù) isnull()
功能:返回一個(gè)布爾值,判斷變量是否包含非法的數(shù)據(jù).
格式:isnull(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果:false
21.函數(shù) Isnumeric()
功能:返回一個(gè)布爾值,判斷變量是否為數(shù)字變量,或者是可以轉(zhuǎn)換成數(shù)字的其它變量.
格式:isnumeric(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果: true.
22.函數(shù) Isobject()
功能:返回一個(gè)布爾值,判斷變量是否為對(duì)象的變量,
格式:isobject(expression)
參數(shù):expression 是任意的變量.
例子:
結(jié)果: true
23.函數(shù): Lbound()
功能:返回一個(gè)數(shù)組的下界.
格式:Lbound(arrayname[,dimension])
參數(shù):arrayname 是數(shù)組變量,dimension 是任意項(xiàng)
例子:
結(jié)果:0
24.函數(shù) Lcase()
功能:將一字符類型變量的字符全部變換小寫字符.
格式:Lcase(string)
參數(shù):string是字串變量
例子:
結(jié)果:this is lcase!
25.函數(shù) left()
功能:截取一個(gè)字符串的前部分;
格式:left(string,length)
參數(shù):string字符串,length截取的長度.
例子:
結(jié)果:this i
26.函數(shù) len()
功能:返回字符串長度或者變量的字節(jié)長度
格式:len(string |varname)
參數(shù):string字符串;varname任意的變量名稱
例子:
結(jié)果:15
27.函數(shù) ltrim()
功能:去掉字符串前的空格.
格式:ltrim(string)
參數(shù):string 字串.
例子:
結(jié)果:Today
29.函數(shù) minute()
功能:返回一數(shù)值, 表示分鐘
格式:minute(time)
參數(shù): time是時(shí)間變量
例子:
結(jié)果:23
30.函數(shù) month()
功能:返回一數(shù)值, 表示月份
格式:month(time)
參數(shù):time是日期變量
例子:
結(jié)果:9
31.函數(shù) monthname()
功能:返回月份的字符串(名稱).
格式:Monthname(date [,abb])
參數(shù):date是日期變量,abb=true時(shí) 則月份的縮寫,
例子:
結(jié)果:April
32.函數(shù) Now()
功能:返回系統(tǒng)的當(dāng)前時(shí)間和日期.
格式:now()
參數(shù):無
例子:
結(jié)果: 05/10/00 8:45:32 pm
33.函數(shù): replace()
功能:在字串中查找,替代指定的字串.
格式:replace(strtobesearched,strsearchfor,strreplacewith
[,start[,count[,compare]]])
參數(shù):strtobesearched是字串; strsearchfor是被查找的子字串;strreplacewith
是用來替代的子字串.start,count,compare 是任意選項(xiàng).
例子:
結(jié)果:this is an orange.
34.函數(shù) right()
功能:截取一個(gè)字符串的后部分
格式:right(string,length)
參數(shù):string字符串,length截取的長度.
例子:
結(jié)果:st!
35.函數(shù) rnd()
功能:返回一個(gè)隨機(jī)數(shù)值
格式:rnd[(number)]
參數(shù):number是任意數(shù)值.
例子:
結(jié)果:0/1數(shù)值之一,無randomize(), 則不能產(chǎn)生隨機(jī)數(shù).
36.函數(shù)round()
功能:完整數(shù)值
格式:round(expression[,numright])
參數(shù):expression數(shù)字表達(dá)式;numright任意選項(xiàng).
例子:
結(jié)果: 12
37.函數(shù) rtrim()
功能:去掉字符串后的空格.
格式:rtrim(string)
參數(shù):string 是字串
例子:
結(jié)果:this is a test!
38.函數(shù) second()
功能:返回一個(gè)整數(shù)值.
格式:second(time)
參數(shù):time是一個(gè)有效的時(shí)間表達(dá)式;
例子:
結(jié)果:30
39.函數(shù) strReverse()
功能:返回與原字串排列逆向的字串.
格式:strreverse(string)
參數(shù):string是字串
例子:
--------------------------------------------------------------------------------
下面為帶例子的:
Array()
FUNCTION: 返回一個(gè)數(shù)組
SYNTAX: Array(list)
ARGUMENTS: 字符,數(shù)字均可
EXAMPLE: <%
Dim myArray()
For i = 1 to 7
Redim Preserve myArray(i)
myArray(i) = WeekdayName(i)
Next
%>
RESULT: 建立了一個(gè)包含7個(gè)元素的數(shù)組myArray
myArray("Sunday","Monday", ... ... "Saturday")
CInt()
FUNCTION: 將一個(gè)表達(dá)式轉(zhuǎn)化為數(shù)字類型
SYNTAX: CInt(expression)
ARGUMENTS: 任何有效的字符均可
EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%>
RESULT: 236
轉(zhuǎn)化字符"234"為數(shù)字"234",如果字符串為空,則返回0值
CreateObject()
FUNCTION: 建立和返回一個(gè)已注冊的ACTIVEX組件的實(shí)例。
SYNTAX: CreateObject(objName)
ARGUMENTS: objName 是任何一個(gè)有效、已注冊的ACTIVEX組件的名字.
EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%>
RESULT:
CStr()
FUNCTION: 轉(zhuǎn)化一個(gè)表達(dá)式為字符串.
SYNTAX: CStr(expression)
ARGUMENTS: expression 是任何有效的表達(dá)式。
EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%>
RESULT: 轉(zhuǎn)化數(shù)字“5”為字符“5”。
Date()
FUNCTION: 返回當(dāng)前系統(tǒng)日期.
SYNTAX: Date()
ARGUMENTS: None.
EXAMPLE: <%=Date%>
RESULT: 8/4/99
DateAdd()
FUNCTION: 返回一個(gè)被改變了的日期。
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: 返回兩個(gè)日期之間的差值 。
SYNTAX: DateDiff(timeinterval,date1,date2 [, firstdayofweek ][,
firstweekofyear]])
ARGUMENTS: timeinterval 表示相隔時(shí)間的類型,如“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: 返回一個(gè)月的第幾日 .
SYNTAX: Day(date)
ARGUMENTS: date 是任何有效的日期。
EXAMPLE: <%=Day(#8/4/99#)%>
RESULT: 4
FormatCurrency()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為貨幣值
SYNTAX: FormatCurrency(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
ARGUMENTS: Digit 指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)值為 -1,指示使用的是
計(jì)算機(jī)的區(qū)域設(shè)置; LeadingDigit 三態(tài)常數(shù),指示是否顯示小數(shù)值小數(shù)點(diǎn)前面的
零。
EXAMPLE: <%=FormatCurrency(34.3456)%>
RESULT: $34.35
FormatDateTime()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為日期或時(shí)間
SYNTAX: FormatDateTime(Date, [, NamedFormat])
ARGUMENTS: NamedFormat 指示所使用的日期/時(shí)間格式的數(shù)值,如果省略,則使用
vbGeneralDate.
EXAMPLE: <%=FormatDateTime("08/4/99", vbLongDate)%>
RESULT: Wednesday, August 04, 1999
FormatNumber()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為數(shù)值.
SYNTAX: FormatNumber(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
ARGUMENTS: Digit 指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)值為 -1,指示使用的是
計(jì)算機(jī)的區(qū)域設(shè)置。; LeadingDigit i指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)值為 -
1,指示使用的是計(jì)算機(jī)的區(qū)域設(shè)置。; Paren 指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)的數(shù)值。默認(rèn)
值為 -1,指示使用的是計(jì)算機(jī)的區(qū)域設(shè)置。; GroupDigit i指示小數(shù)點(diǎn)右側(cè)顯示位數(shù)
的數(shù)值。默認(rèn)值為 -1,指示使用的是計(jì)算機(jī)的區(qū)域設(shè)置。.
EXAMPLE: <%=FormatNumber(45.324567, 3)%>
RESULT: 45.325
FormatPercent()
FUNCTION: 返回表達(dá)式,此表達(dá)式已被格式化為尾隨有 % 符號(hào)的百分比(乘以
100 )。 (%)
SYNTAX: FormatPercent(Expression [, Digit ][, LeadingDigit ][, Paren ][,
GroupDigit]]]])
ARGUMENTS: 同上.
EXAMPLE: <%=FormatPercent(0.45267, 3)%>
RESULT: 45.267%
Hour()
FUNCTION: 以24時(shí)返回小時(shí)數(shù).
SYNTAX: Hour(time)
ARGUMENTS:
EXAMPLE: <%=Hour(#4:45:34 PM#)%>
RESULT: 16
(Hour has been converted to 24-hour system)
Instr()
FUNCTION: 返回字符或字符串在另一個(gè)字符串中第一次出現(xiàn)的位置.
SYNTAX: Instr([start, ] strToBeSearched, strSearchFor [, compare])
ARGUMENTS: Start為搜索的起始值,strToBeSearched接受搜索的字符串
strSearchFor要搜索的字符.compare比較方式(詳細(xì)見ASP常數(shù))
EXAMPLE: <%
strText = "This is a test!!"
pos = Instr(strText, "a")
response.write pos
%>
RESULT: 9
InstrRev()
FUNCTION: 同上,只是從字符串的最后一個(gè)搜索起
SYNTAX: InstrRev([start, ] strToBeSearched, strSearchFor [, compare])
ARGUMENTS: 同上.
EXAMPLE: <%
strText = "This is a test!!"
pos = InstrRev(strText, "s")
response.write pos
%>
RESULT: 13
Int()
FUNCTION: 返回?cái)?shù)值類型,不四舍五入,注意取值是不大于它的整數(shù)。
SYNTAX: Int(number)
ARGUMENTS:
EXAMPLE: <%=INT(32.89)%> <%=int(-3.33)%>
RESULT: 32 -4
IsArray()
FUNCTION: 判斷一對(duì)象是否為數(shù)組,返回布爾值 .
SYNTAX: IsArray(name)
ARGUMENTS:
EXAMPLE: <%
strTest = "Test!"
response.write IsArray(strTest)
%>
RESULT: False
IsDate()
FUNCTION: 判斷一對(duì)象是否為日期,返回布爾值
SYNTAX: IsDate(expression)
ARGUMENTS: expression is any valid expression.
EXAMPLE: <%
strTest = "8/4/99"
response.write IsDate(strTest)
%>
RESULT: True
IsEmpty()
FUNCTION: 判斷一對(duì)象是否初始化,返回布爾值.
SYNTAX: IsEmpty(expression)
ARGUMENTS:
EXAMPLE: <%
Dim i
response.write IsEmpty(i)
%>
RESULT: True
IsNull()
FUNCTION: 判斷一對(duì)象是否為空,返回布爾值.
SYNTAX: IsNull(expression)
ARGUMENTS:
EXAMPLE: <%
Dim i
response.write IsNull(i)
%>
RESULT: False
IsNumeric()
FUNCTION: 判斷一對(duì)象是否為數(shù)字,返回布爾值.
SYNTAX: IsNumeric(expression)
ARGUMENTS:
EXAMPLE: <%
i = "345"
response.write IsNumeric(i)
%>
RESULT: True
就算數(shù)字加了引號(hào),ASP還是認(rèn)為它是數(shù)字。
IsObject()
FUNCTION: 判斷一對(duì)象是否為對(duì)象,返回布爾值.
SYNTAX: IsObject(expression)
ARGUMENTS:
EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)
%>
RESULT: True
LBound()
FUNCTION: 返回指定數(shù)組維的最小可用下標(biāo).
SYNTAX: Lbound(arrayname [, dimension])
ARGUMENTS: ; dimension 指明要返回哪一維下界的整數(shù)。使用 1 表示第一維,2
表示第二維,以此類推。如果省略 dimension 參數(shù),默認(rèn)值為 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個(gè)字符以前的字符(含第length個(gè)字符).
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: 返回時(shí)間的分釧.
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個(gè)字符以前的字符(含第length個(gè)字符).
SYNTAX: Right(string, length)
ARGUMENTS: .
EXAMPLE: <%
strTest = "This is an test!"
response.write Right(strTest, 3)
%>
RESULT: st!
Rnd()
FUNCTION: 產(chǎn)生一個(gè)隨機(jī)數(shù).
SYNTAX: Rnd [ (number) ]
ARGUMENTS:
EXAMPLE: <%
Randomize()
response.write RND()
%>
RESULT: 任何一個(gè)在0 到 1 之間的數(shù)
Round()
FUNCTION: 返回按指定位數(shù)進(jìn)行四舍五入的數(shù)值.
SYNTAX: Round(expression [, numRight])
ARGUMENTS: numRight數(shù)字表明小數(shù)點(diǎn)右邊有多少位進(jìn)行四舍五入。如果省略,則
Round 函數(shù)返回整數(shù).
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: 返回系統(tǒng)時(shí)間.
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: 返回指定數(shù)組維數(shù)的最大可用下標(biāo).
SYNTAX: Ubound(arrayname [, dimension])
ARGUMENTS: ; dimension (optional) 指定返回哪一維上界的整數(shù)。1 表示第一
維,2 表示第二維,以此類推。如果省略 dimension 參數(shù),則默認(rèn)值為 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(數(shù)字)詳見"asp常數(shù)"
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 值,指明是否縮寫表示星期各天的名稱。如果省
略, 默認(rèn)值為 False,即不縮寫星期各天的名稱.firstdayofweek指明星期第一天的
數(shù)值
EXAMPLE: <%
d = #8/4/99#
response.write WeekdayName(Weekday(d))
%>
RESULT: Wednesday
Year()
FUNCTION: 返回當(dāng)前的年份.
SYNTAX: Year(date)
ARGUMENTS:
EXAMPLE: <%=Year(#8/4/99#)%>
RESULT: 1999
相關(guān)文章
ASP初學(xué)者常犯的幾個(gè)錯(cuò)誤(ZT)
ASP初學(xué)者常犯的幾個(gè)錯(cuò)誤(ZT)...2007-01-01給萬博系統(tǒng)的新聞系統(tǒng)增加分頁功能[配有詳細(xì)說明]
給萬博系統(tǒng)的新聞系統(tǒng)增加分頁功能[配有詳細(xì)說明]...2007-03-03ASP編程入門進(jìn)階(二):認(rèn)識(shí)表單
ASP編程入門進(jìn)階(二):認(rèn)識(shí)表單...2007-01-01ASP開發(fā)網(wǎng)頁牢記注意事項(xiàng)
ASP開發(fā)網(wǎng)頁牢記注意事項(xiàng)...2007-03-03IIS 錯(cuò)誤 Server Application Error 詳細(xì)解決方法
IIS 錯(cuò)誤 Server Application Error 詳細(xì)解決方法...2007-02-02