|
[ 2006-05-02 11:36:22 | 作者: Lspcieee ]
Array()
作用:返回一個數(shù)組 語法:Array(list) 適用的類型:字符,數(shù)字均可 <% Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i) Next %> 結果:建立了一個包含7個元素的數(shù)組myArray myArray("Sunday","Monday", ... ... "Saturday") CInt() 作用:將一個表達式轉化為數(shù)字類型 語法:CInt(表達式) 適用的類型:任何有效的字符均可 <% f = "234" response.write cINT(f) + 2 %> 結果:236 轉化字符"234"為數(shù)字234,如果字符串為空,則返回0值 CreateObject() 作用: 建立和返回一個已注冊的ACTIVEX組件的實例。 語法: CreateObject(objName) 適用的類型: objName 是任何一個有效、已注冊的ACTIVEX組件的名字. <% Set con = Server.CreateObject("ADODB.Connection") %> CStr() 作用: 轉化一個表達式為字符串. 語法: CStr(expression) 適用類型: expression 是任何有效的表達式 <% s = 3 + 2 response.write("The 結果 is: " & cStr(s)) %> 結果: 轉化數(shù)字5為字符“5”。 Date() 作用: 返回當前系統(tǒng)日期. 語法: Date() 適用的類型: None. <%=Date%> 結果: 8/4/99 DateAdd() 作用: 返回一個被改變了的日期。 語法: DateAdd(timeinterval,number,date) 說明: timeinterval為所要加入的時間間隔類型; number 為要添加的數(shù)量; 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"; 當當前日期格式為time,那么 "h" = "hour"; "s" = "second"; DateDiff() 作用: 返回兩個日期之間的差值 。 語法: DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear >>) 說明: timeinterval 表示相隔時間的類型,如“M“表示“月”。 <% fromDate = #8/4/99# toDate = #1/1/2000# response.write("There are " & _ DateDiff("d",fromDate,toDate) & _ " days to millenium from 8/4/99." %> 結果: There are150daysto millenium from 8/4/99. Day() 作用: 返回一個月的第幾日 . 語法: Day(date) 說明: date 是任何有效的日期。 <%=Day(#8/4/99#)%> 結果: 4 FormatCurrency() 作用: 返回表達式,此表達式已被格式化為貨幣值 語法: FormatCurrency(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit >>>>) 說明: Digit 指示小數(shù)點右側顯示位數(shù)的數(shù)值。默認值為 -1,指示使用的是計算機的區(qū)域設置; LeadingDigit 三態(tài)常數(shù),指示是否顯示小數(shù)值小數(shù)點前面的零 <%=FormatCurrency(34.3456)%> 結果: $34.35 FormatDateTime() 作用: 返回表達式,此表達式已被格式化為日期或時間 語法: FormatDateTime(Date, [, NamedFormat >) 說明: NamedFormat 指示所使用的日期/時間格式的數(shù)值,如果省略,則使用 vbGeneralDate. <%=FormatDateTime("08/4/99", vbLongDate)%> 結果: Wednesday, August 04, 1999 FormatNumber() 作用: 返回表達式,此表達式已被格式化為數(shù)值. 語法: FormatNumber(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit >>>>) 說明: Digit 指示小數(shù)點右側顯示位數(shù)的數(shù)值。默認值為 -1,指示使用的是計算機的區(qū)域設置。; LeadingDigit i指示小數(shù)點右側顯示位數(shù)的數(shù)值。默認值為 -1,指示使用的是計算機的區(qū)域設置。; Paren 指示小數(shù)點右側顯示位數(shù)的數(shù)值。默認值為 -1,指示使用的是計算機的區(qū)域設置。; GroupDigit i指示小數(shù)點右側顯示位數(shù)的數(shù)值。默認值為 -1,指示使用的是計算機的區(qū)域設置 <%=FormatNumber(45.324567, 3)%> 結果: 45.325 FormatPercent() 作用: 返回表達式,此表達式已被格式化為尾隨有 % 符號的百分比(乘以 100 )。 (%) 語法: FormatPercent(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit >>>>) 說明: 同上. <%=FormatPercent(0.45267, 3)%> 結果: 45.267% Hour() 作用: 以24時返回小時數(shù). 語法: Hour(time) 說明: <%=Hour(#4:45:34 PM#)%>結果: 16 Instr() 作用: 返回字符或字符串在另一個字符串中第一次出現(xiàn)的位置. 語法: Instr([start, > strToBeSearched, strSearchFor [, compare>) 說明: Start為搜索的起始值,strToBeSearched接受搜索的字符串 strSearchFor要搜索的字符compare 比較方式(詳細見ASP常數(shù)) <% strText = "This is a test!!" pos = Instr(strText, "a") response.write pos %> 結果: 9 InstrRev() 作用: 同上,只是從字符串的最后一個搜索起 語法: InstrRev([start, > strToBeSearched, strSearchFor [, compare>) 說明: 同上. <% strText = "This is a test!!" pos = InstrRev(strText, "s") response.write pos %> 結果: 13 Int() 作用: 返回數(shù)值類型,不四舍五入。 語法: Int(number) 說明: <%=INT(32.89)%> 結果: 32 IsArray() 作用: 判斷一對象是否為數(shù)組,返回布爾值 . 語法: IsArray(name) 說明: <% strTest = "Test!" response.write IsArray(strTest) %> 結果: False IsDate() 作用: 判斷一對象是否為日期,返回布爾值語法: IsDate(expression) 說明: expression is any valid expression. <% strTest = "8/4/99" response.write IsDate(strTest) %> 結果: True IsEmpty() 作用: 判斷一對象是否初始化,返回布爾值. 語法: IsEmpty(expression) 說明: <% Dim i response.write IsEmpty(i) %> 結果: True IsNull() 作用: 判斷一對象是否為空,返回布爾值. 語法: IsNull(expression) 說明: <% Dim i response.write IsNull(i) %> 結果: False IsNumeric() 作用: 判斷一對象是否為數(shù)字,返回布爾值. 語法: IsNumeric(expression) 說明: <% i = "345" response.write IsNumeric(i) %> 結果: True 就算數(shù)字加了引號,ASP還是認為它是數(shù)字。 IsObject() 作用: 判斷一對象是否為對象,返回布爾值. 語法: IsObject(expression) 說明: <% Set con = Server.CreateObject( "ADODB.Connection") response.write IsObject(con) %> 結果: True LBound() 作用: 返回指定數(shù)組維的最小可用下標. 語法: Lbound(arrayname [, dimension >) 說明: dimension 指明要返回哪一維下界的整數(shù)。使用 1 表示第一維,2 表示第二維,以此類 推。如果省略 dimension 參數(shù),默認值為 1. <% i = Array( "Monday","Tuesday","Wednesday") response.write LBound(i) %>結果: 0 LCase() 作用: 返回字符串的小寫形式 語法: Lcase(string) 說明: string is any valid string expression. <% strTest = "This is a test!" response.write LCase(strTest) %> 結果: this is a test! Left() 作用: 返回字符串左邊第length個字符以前的字符(含第length個字符). 語法: Left(string, length) 說明: <% strTest = "This is a test!" response.write Left(strTest, 3) %> 結果: Thi Len() 作用: 返回字符串的長度. 語法: Len(string | varName) 說明: <% strTest = "This is a test!" response.write Len(strTest) %> 結果: 15 LTrim() 作用: 去掉字符串左邊的空格. 語法: LTrim(string) 說明: <% strTest = " This is a test!" response.write LTrim(strTest) %> 結果: This is a test! Mid() 作用: 返回特定長度的字符串(從start開始,長度為length). 語法: Mid(string, start [, length >) 說明: <% strTest = "This is a test! Today is Monday." response.write Mid(strTest, 17, 5) %> 結果: Today Minute() 作用: 返回時間的分釧. 語法: Minute(time) 說明: <%=Minute(#12:45:32 PM#)%> 結果: 45 Month() 作用: 返回日期. 語法: Month(date) 說明: date is any valid date expression. <%=Month(#08/04/99#)%>結果: 8 MonthName() 作用: Returns a string identifying the specified month. 語法: MonthName(month, [, Abb >) 說明: 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. <%=MonthName(Month(#08/04/99#))%> 結果: August Now() 作用: Returns the current system date and time.返回當前系統(tǒng)時間 語法: Now() 說明: None <%=Now%> 結果: 8/4/99 9:30:16 AM Replace() 作用: Returns a string in which a specified sub-string has been replaced with another substring a specified number of times. 語法: Replace(strToBeSearched, strSearchFor, strReplaceWith [, start [, count [, compare >>>) 說明: 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. <% strTest = "This is an apple!" response.write Replace(strTest, "apple", "orange") %> 結果: This is an orange! Right() 作用: 返回字符串右邊第length個字符以前的字符(含第length個字符). 語法: Right(string, length) 說明: . <% strTest = "This is an test!" response.write Right(strTest, 3) %> 結果: st! Rnd() 作用: 產(chǎn)生一個隨機數(shù). 語法: Rnd [ (number) > 說明: <% Randomize() response.write RND() %> 結果: 任何一個在0 到 1 之間的數(shù) Round() 作用: 返回按指定位數(shù)進行四舍五入的數(shù)值. 語法: Round(expression [, numRight >) 說明: numRight數(shù)字表明小數(shù)點右邊有多少位進行四舍五入。如果省略,則 Round 函數(shù)返回整數(shù). <% i = 32.45678 response.write Round(i) %> 結果: 32 Rtrim() 作用: 去掉字符串右邊的空格字符串. 語法: Rtrim(string) 說明: <% strTest = "This is a test!! " response.write RTrim(strTest) %> 結果: This is a test!! Second() 作用: 返回秒. 語法: Second(time) 說明: <%=Second(#12:34:28 PM#)%> 結果: 28 StrReverse() 作用: 反排一字符串 語法: StrReverse(string) 說明: <% strTest = "This is a test!!" response.write StrReverse(strTest) %> 結果: !!tset a si sihT Time() 作用: 返回系統(tǒng)時間. 語法: Time() 說明: . <%=Time%>結果: 9:58:28 AM Trim() 作用: 去掉字符串左右的空格. 語法: Trim(string) 說明: string is any valid string expression. <% strTest = " This is a test!! " response.write Trim(strTest) %> 結果: This is a test!! UBound() 作用: 返回指定數(shù)組維數(shù)的最大可用下標. 語法: Ubound(arrayname [, dimension >) 說明: dimension (optional) 指定返回哪一維上界的整數(shù)。1 表示第一維,2 表示第二維,以此類推。如果省略 dimension 參數(shù),則默認值為 1. <% i = Array( "Monday","Tuesday","Wednesday") response.write UBound(i) %> 結果: 2 UCase() 作用: 返回字符串的大寫形式. 語法: UCase(string) 說明: <% strTest = "This is a test!!" response.write UCase(strTest) %> 結果: THIS IS A TEST!! VarType() 作用: 返回指示變量子類型的值 語法: VarType(varName) 說明: <% i = 3 response.write varType(i) %> 結果: 2(數(shù)字)詳見 "asp常數(shù)" WeekDay() 作用: 返回在一周的第幾天. 語法: WeekDay(date [, firstdayofweek >) 說明: . <% d = #8/4/99# response.write Weekday(d) %> 結果: 4(星期三) WeekDayName() 作用: 返回一周第幾天的名字. 語法: WeekDayName(weekday [, Abb [, firstdayofweek >>) 說明: Abb可選。Boolean 值,指明是否縮寫表示星期各天的名稱。如果省略, 默認值為 False,即不縮寫星期各天的名稱.firstdayofweek指明星期第一天的數(shù)值 <% d = #8/4/99# response.write WeekdayName(Weekday(d)) %> 結果: Wednesday Year() 作用: 返回當前的年份. 語法: Year(date) 說明: <%=Year(#8/4/99#)%> |
|
|