Asp 函數(shù)介紹

字號:


    1.函數(shù)array()
    功能:創(chuàng)建一個(gè)數(shù)組變量
    格式:array(list)
    參數(shù):list 為數(shù)組變量中的每個(gè)數(shù)值列,中間用逗號間隔
    例子:
    <% i = array ("1","2",3) %>
    結(jié)果: i 被賦予為數(shù)組
    2.函數(shù)Cint()
    功能:將一表達(dá)式/其它類型的變量轉(zhuǎn)換成整數(shù)類型(int)
    格式:Cint(expression)
    參數(shù):expression 是任何有效的表達(dá)式/其它類型的變量
    例子:
    <%
    f = "234"
    response.write cINT(f) + 2
    %>
    結(jié)果: 236
    函數(shù)Cint()將字符"234"轉(zhuǎn)換 成整數(shù)234.如果表達(dá)式為空, 或者無效時(shí),返回值為0;
    3.函數(shù):Creatobject()
    功能:創(chuàng)建及返回一個(gè)ActiveX對象.
    格式:Creatobject(obname)
    參數(shù):obname 是對象的名稱
    例子:
    <%
    Set con = Server.createObject("ADODB.Connection")
    %>
    結(jié)果:
    4.函數(shù)Cstr()
    功能:將一表達(dá)式/其它類型的變量轉(zhuǎn)換成字符類型(string)
    格式:Cstr(expression)
    參數(shù):expression是任何有效的表達(dá)式/其它類型的變量
    例子:
    <%
    s = 3 + 2
    response.write "The result is: " & cStr(s)
    %>
    結(jié)果:函數(shù)Cstr()將整數(shù) 5 轉(zhuǎn)換 成字符"5".
    5.函數(shù)Date()
    功能:返回當(dāng)前系統(tǒng)(server端)的日期
    格式:Date()
    參數(shù):無
    例子<% date () %>
    結(jié)果:05/10/00
    6.函數(shù)Dateadd()
    功能:計(jì)算某個(gè)指定的時(shí)間和
    格式:dateadd(timeinterval,number,date)
    參數(shù):timeinterval是時(shí)間單位(月,日..); number是時(shí)間間隔值,date是時(shí)間始點(diǎn).
    例子:
    <%
    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
    %>
    結(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).
    例子:
    <%
    fromDate = #8/4/99#
    toDate = #1/1/2000#
    response.write "There are " & _
    DateDiff("d",fromDate,toDate) & _
    " days to millenium from 8/4/99."
    %>
    結(jié)果:There are 150 days to millenium from 8/4/99.
    8.函數(shù)day()
    功能:返回一個(gè)整數(shù)值,對應(yīng)于某月的某日
    格式:day(date)
    參數(shù):date是一個(gè)有效的日期表達(dá)式;
    例子lt;% =date(#8/4/99#) %>
    結(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).
    例子<%=FormatCurrency(34.3456)%>
    結(jié)果34.35
    10.函數(shù)Formatdatetime()
    功能:格式化日期表達(dá)式/變量
    格式:formatdatetime(date[,nameformat])
    參數(shù):date為有效的日期表達(dá)式/變量;nameformat是指定的日期格式常量名稱.
    例子<% =formatdatetime("08/04/99",vblongdate) %>
    結(jié)果:Wednesday,August 04,1999
    21.函數(shù)Isnumeric()
    功能:返回一個(gè)布爾值,判斷變量是否為數(shù)字變量,或者是可以轉(zhuǎn)換成數(shù)字的其它變量.
    格式:isnumeric(expression)
    參數(shù):expression 是任意的變量.
    例子:
    <%
    i="234"
    response.write isnumeric(i)
    %>
    結(jié)果: true.
    22.函數(shù)Isobject()
    功能:返回一個(gè)布爾值,判斷變量是否為對象的變量,
    格式:isobject(expression)
    參數(shù):expression 是任意的變量.
    例子:
    <%
    set con =server.creatobject("adodb.connection")
    response.write isobject(con)
    %>
    結(jié)果: true
    23.函數(shù):Lbound()
    功能:返回一個(gè)數(shù)組的下界.
    格式:Lbound(arrayname[,dimension])
    參數(shù):arrayname 是數(shù)組變量,dimension 是任意項(xiàng)
    例子:
    <%
    i = array("1","2","3")
    response.write lbound(i)
    %>
    結(jié)果:0
    24.函數(shù)Lcase()
    功能:將一字符類型變量的字符全部變換小寫字符.
    格式:Lcase(string)
    參數(shù):string是字符串變量
    例子:
    <%
    str="THIS is Lcase!"
    response.write Lcase(str)
    %>
    結(jié)果:this is lcase!
    25.函數(shù)left()
    功能:截取一個(gè)字符串的前部分;
    格式:left(string,length)
    參數(shù):string字符串,length截取的長度.
    例子: <% =left("this is a test!",6) %>
    結(jié)果:this i
    26.函數(shù)len()
    功能:返回字符串長度或者變量的字節(jié)長度
    格式:len(string |varname)
    參數(shù):string字符串;varname任意的變量名稱
    例子:
    <%
    strtest="this is a test!"