ASP中常用的函數(shù)和詳細(xì)說(shuō)明第2/2頁(yè)
更新時(shí)間:2007年03月02日 00:00:00 作者:
20.函數(shù)month()
功能:返回一數(shù)值, 表示月份
格式:month(time)
參數(shù):time是日期變量
例子<% =month(#08/09/99) %>
結(jié)果:9
21.函數(shù)monthname()
功能:返回月份的字符串(名稱(chēng)).
格式:Monthname(date [,abb])
參數(shù): date是日期變量,abb=true時(shí) 則月份的縮寫(xiě),
例子:
<% =monthname(#4/5/99#) %>
結(jié)果:April
22.函數(shù)Now()
功能:返回系統(tǒng)的當(dāng)前時(shí)間和日期.
格式:now()
參數(shù):無(wú)
例子:
<% =now() %>
結(jié)果: 05/10/00 8:45:32 pm
23.函數(shù):replace()
功能:在字符串中查找,替代指定的字符串.
格式:replace(strtobesearched,strsearchfor,strreplacewith [,start[,count[,compare]]])
參數(shù):strtobesearched是字符串; strsearchfor是被查找的子字符串;strreplacewith 是用來(lái)替代的子字符串.start,count,compare 是任意選項(xiàng).
例子:
<%
strtest="this is an apple."
response.write replace(strtest,"apple","orange")
%>
結(jié)果:this is an orange.
24.函數(shù)right()
功能:截取一個(gè)字符串的后部分
格式:right(string,length)
參數(shù):string字符串,length截取的長(zhǎng)度.
例子:
<%
strtest="this is a test!"
response.write right(strtest,3)
%>
結(jié)果:st!
25.函數(shù)rnd()
功能:返回一個(gè)隨機(jī)數(shù)值
格式:rnd[(number)]
參數(shù):number是任意數(shù)值.
例子:
<%
randomize()
response.write rnd()
%>
結(jié)果:0/1數(shù)值之一,無(wú)randomize(), 則不能產(chǎn)生隨機(jī)數(shù).
26.函數(shù)round()
功能:完整數(shù)值
格式:round(expression[,numright])
參數(shù):expression數(shù)字表達(dá)式;numright任意選項(xiàng).
例子:
<%
i=12.33654
response.write round(i)
%>
結(jié)果: 12
27.函數(shù)rtrim()
功能:去掉字符串后的空格.
格式:rtrim(string)
參數(shù):string 是字符串
例子:
<%
response.write rtrim("this is a test! ")
%>
結(jié)果:this is a test!
28.函數(shù)second()
功能:返回一個(gè)整數(shù)值.
格式:second(time)
參數(shù):time是一個(gè)有效的時(shí)間表達(dá)式;
例子lt;% =second(# 12:28:30#) %>
結(jié)果:30
29.函數(shù)strReverse()
功能:返回與原字符串排列逆向的字符串.
格式:strreverse(string)
參數(shù):string是字符串
例子<% =strreverse("this is a test!")
結(jié)果:!tset a si siht
30.函數(shù)time()
功能:返回當(dāng)前系統(tǒng)的時(shí)間值.
格式:time()
參數(shù):無(wú)
結(jié)果:9:58:28 Am
31.函數(shù)trim()
功能:刪去字符串前,后的空格.
格式:trim(string)
參數(shù):string 字符串.
例子:
<%
strtest=" this is a test! "
response.write trim(strtest)
%>
結(jié)果:this is a test!
32.函數(shù)UBound()
功能:返回一個(gè)數(shù)組的上界.
格式:Ubound(expression [,dimension])
參數(shù):expression 是數(shù)組表達(dá)式/數(shù)組變量,dimension 是任意項(xiàng)
例子:
<%
i = array("1","2","3")
response.write ubound(i)
%>
結(jié)果: 2
33.函數(shù):UCase()
功能:將一字符類(lèi)型變量的字符全部變換成大寫(xiě)字符.
格式:Ucase(string)
參數(shù):string是字符串變量
例子:
<%
str="THIS is Lcase!"
response.write Lcase(str)
%>
結(jié)果:THIS IS LCASE!
34.函數(shù)Vartype()
功能:返回變量的常量代碼(整數(shù))
格式:Vartype(varname)
參數(shù):varname是任何類(lèi)型的變量名稱(chēng).
例子:
<%
i=5
response.write vartype(i)
%>
結(jié)果:2 (2表示整數(shù),須要參考ASP常量代碼.)
35.函數(shù)Weekday()
功能:返回一個(gè)整數(shù),對(duì)應(yīng)一周中的第幾天.
格式:Weekday(date [,firstofweek])
參數(shù): date為日期變量,firstofweek為任選項(xiàng).
例子:
<%
d= # 5/9/00 #
response.write weekday(d) %>
結(jié)果:3(3 表示是星期二)
36.函數(shù)weekdayname()
功能:返回字符串,對(duì)應(yīng)星期幾.
格式:weekdayname(weekday[,abb[,firstdayofweek]])
參數(shù):weekday為日期變量,abb,firstdayofweek為任選項(xiàng).
例子:
<%
d = #8/4/99#
response.write weekdayname(d)
%>
結(jié)果: Wednesday
37.函數(shù)year()
功能:返回日期表達(dá)式所在的年份.
格式:year(date)
參數(shù): date是有效的日期表達(dá)式
例子:
<% =year(#8/9/99#) %>
結(jié)果:1999
38.函數(shù)Mod()功能:取余數(shù).
例子:3 Mod 2
結(jié)果:1
我先介紹一下Split函數(shù)的用法:
返回值數(shù)組 = Split("字符串","分割符")
39.split函數(shù)的應(yīng)用
作者:李春光 轉(zhuǎn)貼自:本站原創(chuàng) 點(diǎn)擊數(shù):113 文章錄入:
split 是一個(gè)分隔字符串的函數(shù),它的作用是把用特定分隔符隔開(kāi)的字符串轉(zhuǎn)化為一個(gè)數(shù)組,這在編程中用的比較多,如上傳多張圖片,在數(shù)庫(kù)中僅能用一個(gè)字段存儲(chǔ)的情況下,split就起作用了,下面是一個(gè)具體的例子,和數(shù)組結(jié)合使用.
<%
dim str1
str1="icerain|fengling|windbell|"
aryReturn=split(str1,"|")
response.write "返回的是否為數(shù)組"&IsArray(aryReturn)
response.write "<br>"
for i=LBound(aryReturn) TO UBound(aryReturn)
response.write aryReturn(i)
response.write "<br>"
next
response.end
%>
Rnd()
函數(shù)產(chǎn)生一個(gè)隨機(jī)數(shù).
表達(dá)式 Rnd [ (number) ]
實(shí)例: <%
Randomize()
response.write RND()
%>
返回結(jié)果: 任何一個(gè)在0 到 1 之間的數(shù)
相關(guān)文章
用ASP開(kāi)發(fā)網(wǎng)頁(yè)需要牢記的注意事項(xiàng)
ASP開(kāi)發(fā)網(wǎng)頁(yè)需要牢記的注意事項(xiàng),使用asp的朋友可以看看2006-06-06ServerVariables集合檢索預(yù)定的環(huán)境變量
ServerVariables集合檢索預(yù)定的環(huán)境變量...2007-02-02