time
根據系統返回當前時間。
timeserial(hour,minute,second)
返回date變量體。
timevalue(time)
返回包含時間的date變量體。
trim(string)
刪除字符串string兩邊的多余空格。
typename(varname)
返回子類型的名稱。關于返回值請參看后面“變量類型常數”一節。
ubound(arrayname)
返回數組某維的上邊界。缺省維數時,為第一維。
ucase(string)
用大寫字母格式格式化字符串string。
vartype(varname)
返回子類型的值。關于返回值請參看后面“變量類型常數”一節。
weekday(date,)
用數字形式返回星期幾。關于參數firstdayofweek的值請參看后面“變量類型常數”一節。
weekdayname(weekday,abbreviate,firstdayofweek)
用名稱形式返回星期幾。關于參數firstdayofweek的值請參看后面“變量類型常數”一節。
year(date)
根據參數date返回年份。
等待 發表于 2008-2-25 17:04
部分附實例和講解
IsNumeric()
函數判斷一對象是否為數字, | 布爾值.
表達式 IsNumeric(expression)
實例: <%
I = "345"
response.write IsNumeric(I)
%>
| 結果: True
就算數字加了引號,ASP還是認為它是數字。
IsObject()
函數判斷一對象是否為對象, | 布爾值.
表達式 IsObject(expression)
實例: <%
Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)
%>
| 結果: True
Lbound()
函數 | 指定數組維的最小可用下標.
表達式 Lbound(arrayname [, dimension])
實例: <%
I = Array("Monday","Tuesday","Wednesday")
response.write Lbound(I)
%>
| 結果: 0
Lcase()
函數 | 字符串的小寫形式
表達式 Lcase(string)
實例: <%
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)
實例: <%=Month(#08/04/99#)%>
| 結果: 8
MonthName()
函數 | 指定月份
表達式 MonthName(month, [, Abb])
實例: <%=MonthName(Month(#08/04/99#))%>
| 結果: August
Now()
函數 | 系統時間
表達式 Now()
實例: <%=Now%>
| 結果: 9/9/00 9:30:16 AM
Right()
函數 | 字符串右邊第length個字符以前的字符(含第length個字符).
表達式 Right(string, length)
實例: <%
strTest = "This is an test!"
response.write Right(strTest, 3)
%>
| 結果: st!
Rnd()
函數產生一個隨機數.
表達式 Rnd [ (number) ]
實例: <%
Randomize()
response.write RND()
%>
| 結果: 任何一個在0 到 1 之間的數
等待 發表于 2008-2-25 17:08
instr 查找 索引 函數
instr 函數
表達式:
InStr([start, ]string1, string2[, compare])
描述:
start
可選參數。為數值表達式,設置每次搜索的起點。如果省略,將從第一個字符的位置開始。如果 start 包含 Null,將發生錯誤。如果指定了 compare 參數,則一定要有 start 參數。
string1
必要參數。接受搜索的字符串表達式。
string2
必要參數。被搜索的字符串表達式。
Compare
可選參數。指定字符串比較。如果 compare 是 Null,將發生錯誤。如果省略 compare,Option Compare 的設置將決定比較的類型。
compare 參數設置為:
常數
值
描述
vbUseCompareOption
-1
使用Option Compare 語句設置執行一個比較。
vbBinaryCompare
0
執行一個二進制比較。
vbTextCompare
1
執行一個按照原文的比較。
vbDatabaseCompare
2
僅適用于Microsoft Access,執行一個基于數據庫中信息的比較。
返回值
返回0、1、2、-1或Null等。
異常/錯誤
無
描述InStr([start, ]string1, string2[, compare])
返回指定一字符串在另一字符串中最先出現的位置。在字符串string1中,從start開始找string2,省略start時從string1頭開始找。找不到時,函數值為0。
如果
InStr返回
string1 為零長度
0
string1 為 Null
Null
string2 為零長度
Start
string2 為 Null
Null
string2 找不到
0
在 string1 中找到string2
找到的位置
start > string2
0
示例
本示例使用 InStr 函數來查找某字符串在另一個字符串中首次出現的位置。
Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' 被搜索的字符串。
SearchChar = "P" ' 要查找字符串 "P"。
' 從第四個字符開始,以文本比較的方式找起。返回值為 6(小寫 p)。
' 小寫 p 和大寫 P 在文本比較下是一樣的。
MyPos = Instr(4, SearchString, SearchChar, 1)
' 從第一個字符開使,以二進制比較的方式找起。返回值為 9(大寫 P)。
' 小寫 p 和大寫 P 在二進制比較下是不一樣的。
MyPos = Instr(1, SearchString, SearchChar, 0)
' 缺省的比對方式為二進制比較(最后一個參數可省略)。
MyPos = Instr(SearchString, SearchChar) ' 返回 9。
MyPos = Instr(1, SearchString, "W") ' 返回 0。