Asp函數(shù)介紹(37個常用函數(shù))第2/2頁
更新時間:2008年11月22日 12:26:38 作者:
下面的函數(shù)是asp中經(jīng)常用的到呢,大家可以收藏一下經(jīng)常查詢下
16.函數(shù)len()
功能:返回字符串長度或者變量的字節(jié)長度
格式:len(string *varname)
參數(shù):string字符串;varname任意的變量名稱
例子:
<%
strtest="this is a test!"
response.write len(strtest)
%>
結果:15
17.函數(shù)ltrim()
功能:去掉字符串前的空格.
格式:ltrim(string)
參數(shù):string 字符串.
例子: <% =ltrim (" this is a test!")
結果:this is a test!
18.函數(shù)Mid()
功能:從字符串中截取字符串.
格式:mid(string,start [,length])
參數(shù):string字符串,start截取的起點,length要截取的長度.
例子:
<%
strtest="this is a test, Today is Monday!"
response.write mid(strtest,17,5)
%>
結果:Today
19.函數(shù)minute()
功能:返回一數(shù)值, 表示分鐘
格式:minute(time)
參數(shù): time是時間變量
例子lt;% =minute(#12:23:34#) %>
結果:23
20.函數(shù)month()
功能:返回一數(shù)值, 表示月份
格式:month(time)
參數(shù):time是日期變量
例子<% =month(#08/09/99) %>
結果:9
21.函數(shù)monthname()
功能:返回月份的字符串(名稱).
格式:Monthname(date [,abb])
參數(shù): date是日期變量,abb=true時 則月份的縮寫,
例子:
<% =monthname(#4/5/99#) %>
結果:April
22.函數(shù)Now()
功能:返回系統(tǒng)的當前時間和日期.
格式:now()
參數(shù):無
例子:
<% =now() %>
結果: 05/10/00 8:45:32 pm
23.函數(shù):replace()
功能:在字符串中查找,替代指定的字符串.
格式:replace(strtobesearched,strsearchfor,strreplacewith [,start[,count[,compare]]])
參數(shù):strtobesearched是字符串; strsearchfor是被查找的子字符串;strreplacewith 是用來替代的子字符串.start,count,compare 是任意選項.
例子:
<%
strtest="this is an apple."
response.write replace(strtest,"apple","orange")
%>
結果:this is an orange.
24.函數(shù)right()
功能:截取一個字符串的后部分
格式:right(string,length)
參數(shù):string字符串,length截取的長度.
例子:
<%
strtest="this is a test!"
response.write right(strtest,3)
%>
結果:st!
25.函數(shù)rnd()
功能:返回一個隨機數(shù)值
格式:rnd[(number)]
參數(shù):number是任意數(shù)值.
例子:
<%
randomize()
response.write rnd()
%>
結果:0/1數(shù)值之一,無randomize(), 則不能產生隨機數(shù).
26.函數(shù)round()
功能:完整數(shù)值
格式:round(expression[,numright])
參數(shù):expression數(shù)字表達式;numright任意選項.
例子:
<%
i=12.33654
response.write round(i)
%>
結果: 12
27.函數(shù)rtrim()
功能:去掉字符串后的空格.
格式:rtrim(string)
參數(shù):string 是字符串
例子:
<%
response.write rtrim("this is a test! ")
%>
結果:this is a test!
28.函數(shù)second()
功能:返回一個整數(shù)值.
格式:second(time)
參數(shù):time是一個有效的時間表達式;
例子lt;% =second(# 12:28:30#) %>
結果:30
29.函數(shù)strReverse()
功能:返回與原字符串排列逆向的字符串.
格式:strreverse(string)
參數(shù):string是字符串
例子<% =strreverse("this is a test!")
結果:!tset a si siht
30.函數(shù)time()
功能:返回當前系統(tǒng)的時間值.
格式:time()
參數(shù):無
結果:9:58:28 Am
31.函數(shù)trim()
功能:刪去字符串前,后的空格.
格式:trim(string)
參數(shù):string 字符串.
例子:
<%
strtest=" this is a test! "
response.write trim(strtest)
%>
結果:this is a test!
32.函數(shù)UBound()
功能:返回一個數(shù)組的上界.
格式:Ubound(expression [,dimension])
參數(shù):expression 是數(shù)組表達式/數(shù)組變量,dimension 是任意項
例子:
<%
i = array("1","2","3")
response.write ubound(i)
%>
結果: 2
33.函數(shù):UCase()
功能:將一字符類型變量的字符全部變換成大寫字符.
格式:Ucase(string)
參數(shù):string是字符串變量
例子:
<%
str="THIS is Lcase!"
response.write Lcase(str)
%>
結果:THIS IS LCASE!
34.函數(shù)Vartype()
功能:返回變量的常量代碼(整數(shù))
格式:Vartype(varname)
參數(shù):varname是任何類型的變量名稱.
例子:
<%
i=5
response.write vartype(i)
%>
結果:2 (2表示整數(shù),須要參考ASP常量代碼.)
35.函數(shù)Weekday()
功能:返回一個整數(shù),對應一周中的第幾天.
格式:Weekday(date [,firstofweek])
參數(shù): date為日期變量,firstofweek為任選項.
例子:
<%
d= # 5/9/00 #
response.write weekday(d) %>
結果:3(3 表示是星期二)
36.函數(shù)weekdayname()
功能:返回字符串,對應星期幾.
格式:weekdayname(weekday[,abb[,firstdayofweek]])
參數(shù):weekday為日期變量,abb,firstdayofweek為任選項.
例子:
<%
d = #8/4/99#
response.write weekdayname(d)
%>
結果: Wednesday
37.函數(shù)year()
功能:返回日期表達式所在的年份.
格式:year(date)
參數(shù): date是有效的日期表達式
例子:
<% =year(#8/9/99#) %>
結果:1999
38.函數(shù)Mod()功能:取余數(shù).
例子:3 Mod 2
結果:1
相關文章
在asp中使用js的encodeURIComponent方法
encodeURIComponent 方法返回一個已編碼的 URI。如果您將編碼結果傳遞給 decodeURIComponent,那么將返回初始的字符串2012-03-03ASP中保留小數(shù)點后兩位數(shù)的方法(使用FormatNumber)
這篇文章主要介紹了ASP中保留小數(shù)點后兩位數(shù)的方法,使用FormatNumber函數(shù)實現(xiàn),需要的朋友可以參考下2014-06-06ASP去掉字符串頭尾連續(xù)回車和空格的Function
去掉字符串頭尾的連續(xù)的回車和空格 去掉字符串開頭的連續(xù)的回車和空格 去掉字符串末尾的連續(xù)的回車和空格2008-12-12ASP中Null,Empty,Nothing的區(qū)別分析
本文介紹在ASP中,NULL,Empty,Nothing這幾種空值的來源和判斷方法。希望對大家有所幫助。2014-08-08asp IsValidEmail 驗證郵箱地址函數(shù)(email)
驗證郵箱很多在js客戶端驗證了,但是那樣很容易被人破了,我們在服務器上用asp進行驗證的話就應該沒有問題了。2010-05-05Coolite 中前臺獲取 GridPanel 當前選擇行值的代碼
掌握獲取 GridPanel 當前行的各個字段值的方法,需要的朋友可以參考下。2010-06-06asp中向文本框輸出數(shù)據(jù)原樣式的函數(shù)
asp中向文本框輸出數(shù)據(jù)原樣式的函數(shù)...2007-03-03asp下實現(xiàn) 重新排序數(shù)字數(shù)組的代碼
asp下實現(xiàn) 重新排序數(shù)字數(shù)組的代碼...2007-08-08