Array()
函數返回一個數組
表達式 Array(list)
允許數據類型: 字符,數字均可
實例:
<% Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i) Next %>
返回結果: 建立了一個包含7個元素的數組myArray
myArray("Sunday","Monday", ... ... "Saturday")
CInt()
函數將一個表達式轉化為數字類型
表達式 CInt(expression)
允許數據類型: 任何有效的字符均可
實例:
<% f = "234" response.write cINT(f) + 2 %>
返回結果: 236
轉化字符"234"為數字"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) %>
返回結果: 轉化數字“5”為字符“5”。
Date()
函數返回當前系統日期.
表達式 Date()
允許數據類型: None.
實例:
<%=Date%>
返回結果: 9/9/00
DateAdd()
函數返回一個被改變了的日期。
表達式 DateAdd(timeinterval,number,date)
允許數據類型:
timeinterval is the time interval to add;
number is amount of time intervals to add;
and date is the starting date.
實例:
<% currentDate = #9/9/00# newDate = DateAdd("m",3,currentDate) response.write newDate %>
<% currentDate = #12:34:45 PM# newDate = DateAdd("h",3,currentDate) response.write newDate %>
返回結果:
9/9/00
3:34:45 PM
"m" = "month";
"d" = "day";
If currentDate is in time format then,
"h" = "hour";
"s" = "second";
DateDiff()
函數返回兩個日期之間的差值 。
表達式 DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])
允許數據類型: timeinterval 表示相隔時間的類型,如“M“表示“月”。
實例:
<% fromDate = #9/9/00# toDate = #1/1/2000# response.write "There are " & _ DateDiff("d",fromDate,toDate) & _ " days to millenium from 9/9/00." %>
返回結果: 從9/9/00 到2000年還有 150 天.
Day()
函數返回一個月的第幾日 .
表達式 Day(date)
允許數據類型: date 是任何有效的日期。
實例:
<%=Day(#9/9/00#)%>
返回結果: 4
FormatCurrency()
函數返回表達式,此表達式已被格式化為貨幣值
表達式 FormatCurrency(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
允許數據類型: Digit 指示小數點右側顯示位數的數值。默認值為 -1,指示使用的是計算機的區域設置; LeadingDigit 三態常數,指示是否顯示小數值小數點前面的零。
實例:
<%=FormatCurrency(34.3456)%>
返回結果: $34.35
以上就是ASP函數大全的全部內容,希望對大家的學習有所幫助。