◇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 函數Cint()將字符"234"轉換 成整數234.如果表達式為空, 或者無效時,返回值為0; 3.函數:Creatobject() 功能:創建及返回一個ActiveX對象. 格式:Creatobject(obname) 參數:obname 是對象的名稱 例子: <% Set con = Server.CreateObject("ADODB.Connection") %> 結果: 4.函數Cstr() 功能:將一表達式/其它類型的變量轉換成字符類型(string) 格式:Cstr(expression) 參數:expression是任何有效的表達式/其它類型的變量 例子: <% s = 3 + 2 response.write "The result is: " & cStr(s) %> 結果:函數Cstr()將整數 5 轉換 成字符"5". 5.函數Date() 功能:返回當前系統(server端)的日期 格式:Date() 參數:無 例子<% date () %> 結果:05/10/00 6.函數Dateadd() 功能:計算某個指定的時間和 格式:dateadd(timeinterval,number,date) 參數:timeinterval是時間單位(月,日..); number是時間間隔值,date是時間始點. 例子: <% 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 %> 結果: 11/4/99 3:34:45 PM 其中 "m" = "month"; "d" = "day"; 如果是currentDate 格式,則, "h" = "hour"; "s" = "second"; 7.函數Datediff() 功能:計算某量個指定的時間差 格式:datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]]) 參數:timeinterval 是時間單位; date1,date2是有效的日期表達式,firstdayofweek,firstdayofyear 是任意選項. 例子: <% fromDate = #8/4/99# toDate = #1/1/2000# response.write "There are " & _ DateDiff("d",fromDate,toDate) & _ " days to millenium from 8/4/99." %> 結果:There are 150 days to millenium from 8/4/99. 8.函數day() 功能:返回一個整數值,對應于某月的某日 格式:day(date) 參數:date是一個有效的日期表達式; 例子lt;% =date(#8/4/99#) %> 結果:4 9.函數formatcurrency() 功能:轉換成貨幣格式 格式:formatcurrency(expression [,digit[,leadingdigit[,paren[,groupdigit]]]]) 參數:expression 是有效的數字表達式;digit表示小數點后的位數;leadingdigit,paren,groupdigit是任意選項. 例子<%=FormatCurrency(34.3456)%> 結果34.35 10.函數Formatdatetime() 功能:格式化日期表達式/變量 格式:formatdatetime(date[,nameformat]) 參數:date為有效的日期表達式/變量;nameformat是指定的日期格式常量名稱. 例子<% =formatdatetime("08/04/99",vblongdate) %> 結果:Wednesday,August 04,1999 21.函數Isnumeric() 功能:返回一個布爾值,判斷變量是否為數字變量,或者是可以轉換成數字的其它變量. 格式:isnumeric(expression) 參數:expression 是任意的變量. 例子: <% i="234" response.write isnumeric(i) %> 結果: true. 22.函數Isobject() 功能:返回一個布爾值,判斷變量是否為對象的變量, 格式:isobject(expression) 參數:expression 是任意的變量. 例子: <% set con =server.creatobject("adodb.connection") response.write isobject(con) %> 結果: true 23.函數:Lbound() 功能:返回一個數組的下界. 格式:Lbound(arrayname[,dimension]) 參數:arrayname 是數組變量,dimension 是任意項 例子: <% i = array("1","2","3") response.write lbound(i) %> 結果:0 |
|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )
GMT+8, 2024-9-30 21:24 , Processed in 0.214648 second(s), 12 queries , Gzip On, MemCache On.
Powered by Discuz! X3.5
© 2001-2023 Discuz! Team.