asp 類型轉(zhuǎn)換函數(shù)大全
更新時間:2008年10月20日 23:01:33 作者:
asp 類型轉(zhuǎn)換的實現(xiàn)函數(shù)
IsObject()
函數(shù)判斷一對象是否為對象, | 布爾值.
表達式 IsObject(expression)
實例: <%
Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)
%>
| 結果: True
Lbound()
函數(shù) | 指定數(shù)組維的最小可用下標.
表達式 Lbound(arrayname [, dimension])
實例: <%
I = Array("Monday","Tuesday","Wednesday")
response.write Lbound(I)
%>
| 結果: 0
Lcase()
函數(shù) | 字符串的小寫形式
表達式 Lcase(string)
實例: <%
strTest = "This is a test!"
response.write Lcase(strTest)
%>
| 結果: this is a test!
Left()
函數(shù) | 字符串左邊第length個字符以前的字符(含第length個字符).
表達式 Left(string, length)
實例: <%
strTest = "This is a test!"
response.write Left(strTest, 3)
%>
| 結果: Thi
Len()
函數(shù) | 字符串的長度.
表達式 Len(string | varName)
實例: <%
strTest = "This is a test!"
response.write Len(strTest)
%>
| 結果: 15
Ltrim()
函數(shù)去掉字符串左邊的空格.
表達式 Ltrim(string)
實例: <%
strTest = " This is a test!"
response.write Ltrim(strTest)
%>
| 結果: This is a test!
Mid()
函數(shù) | 特定長度的字符串(從start開始,長度為length).
表達式 Mid(string, start [, length])
實例: <%
strTest = "This is a test! Today is Monday."
response.write Mid(strTest, 17, 5)
%>
| 結果: Today
Minute()
函數(shù) | 時間的分鐘.
表達式 Minute(time)
實例: <%=Minute(#12:45:32 PM#)%>
| 結果: 45
Month()
函數(shù) | 日期.
表達式 Month(date)
實例: <%=Month(#08/04/99#)%>
| 結果: 8
MonthName()
函數(shù) | 指定月份
表達式 MonthName(month, [, Abb])
實例: <%=MonthName(Month(#08/04/99#))%>
| 結果: August
Now()
函數(shù) | 系統(tǒng)時間
表達式 Now()
實例: <%=Now%>
| 結果: 9/9/00 9:30:16 AM
Right()
函數(shù) | 字符串右邊第length個字符以前的字符(含第length個字符).
表達式 Right(string, length)
實例: <%
strTest = "This is an test!"
response.write Right(strTest, 3)
%>
| 結果: st!
Rnd()
函數(shù)產(chǎn)生一個隨機數(shù).
表達式 Rnd [ (number) ]
實例: <%
Randomize()
response.write RND()
%>
| 結果: 任何一個在0 到 1 之間的數(shù)
等待 發(fā)表于 2008-2-25 17:08
instr 查找 索引 函數(shù)
instr 函數(shù)
表達式:
InStr([start, ]string1, string2[, compare])
描述:
start
可選參數(shù)。為數(shù)值表達式,設置每次搜索的起點。如果省略,將從第一個字符的位置開始。如果 start 包含 Null,將發(fā)生錯誤。如果指定了 compare 參數(shù),則一定要有 start 參數(shù)。
string1
必要參數(shù)。接受搜索的字符串表達式。
string2
必要參數(shù)。被搜索的字符串表達式。
Compare
可選參數(shù)。指定字符串比較。如果 compare 是 Null,將發(fā)生錯誤。如果省略 compare,Option Compare 的設置將決定比較的類型。
compare 參數(shù)設置為:
常數(shù)
值
描述
vbUseCompareOption
-1
使用Option Compare 語句設置執(zhí)行一個比較。
vbBinaryCompare
0
執(zhí)行一個二進制比較。
vbTextCompare
1
執(zhí)行一個按照原文的比較。
vbDatabaseCompare
2
僅適用于Microsoft Access,執(zhí)行一個基于數(shù)據(jù)庫中信息的比較。
返回值
返回0、1、2、-1或Null等。
異常/錯誤
無
描述InStr([start, ]string1, string2[, compare])
返回指定一字符串在另一字符串中最先出現(xiàn)的位置。在字符串string1中,從start開始找string2,省略start時從string1頭開始找。找不到時,函數(shù)值為0。
如果
InStr返回
string1 為零長度
0
string1 為 Null
Null
string2 為零長度
Start
string2 為 Null
Null
string2 找不到
0
在 string1 中找到string2
找到的位置
start > string2
0
示例
本示例使用 InStr 函數(shù)來查找某字符串在另一個字符串中首次出現(xiàn)的位置。
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)
' 缺省的比對方式為二進制比較(最后一個參數(shù)可省略)。
MyPos = Instr(SearchString, SearchChar) ' 返回 9。
MyPos = Instr(1, SearchString, "W") ' 返回 0。
相關文章
服務端 VBScript 與 JScript 幾個相同特性的寫法與示例
服務端 VBScript 與 JScript 幾個相同特性的寫法與示例...2007-03-03asp實現(xiàn)excel中的數(shù)據(jù)導入數(shù)據(jù)庫
本文給大家匯總介紹了使用asp實現(xiàn)將Excel中數(shù)據(jù)導入到數(shù)據(jù)庫中的方法,需要的朋友可以參考一下2015-09-09從一個網(wǎng)站扒下的asp生成靜態(tài)頁面的代碼 腳本之家特供版
雖然腳本之家以前發(fā)布過相關的代碼,但一些特別的網(wǎng)站不是很完美,最近幫客戶修改系統(tǒng)發(fā)現(xiàn)了這段代碼,發(fā)現(xiàn)還不錯,特提取出來,方便大家使用。2011-07-07