小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

幾個ASP好用的自定義函數(shù)

 天落雨 2006-01-17

cLeft(string, length) 返回指定數(shù)目的從字符串的左邊算起的字符,區(qū)分單雙字節(jié)。

如:
Dim MyString, LeftString
MyString = "文字測試VBSCript"
LeftString = cLeft(MyString, 10)
返回 "文字測試VB"。


MyRandc(n) 生成隨機字符,n為字符的個數(shù)

如:
response.write MyRandn(10)
輸出10個隨機字符


MyRandn(n) 生成隨機數(shù)字,n為數(shù)字的個數(shù)

如:
response.write MyRandn(10)
輸出10個隨機數(shù)字


formatQueryStr(str) 格式化sql中的like字符串.
如:
q = Request("q")
q = formatQueryStr(q)
sql = "select * from [table] where aa like ‘%"& q &"%‘"

GetRnd(min,max) 返回min - max之間的一個隨機數(shù)

如:
response.write GetRnd(100,200)
輸出大于100到200之間的一個隨機數(shù)

函數(shù)代碼:

<%

function cLeft(str,n)
dim str1,str2,alln,Islefted
str2 = ""
alln = 0
str1 = str
Islefted = false
if isnull(str) then
cleft = ""
exit function
end if
for i = 1 to len(str1)
nowstr = mid(str1,i,1)
if asc(nowstr)<0 then
alln = alln + 2
else
alln = alln + 1
end if
if (alln<=n) then
str2 = str2 & nowstr
else
Islefted = true
exit for
end if
next
if Islefted then
str2 = str2 & ".."
end if
cleft = str2
end function


function MyRandc(n) ‘生成隨機字符,n為字符的個數(shù)
dim thechr
thechr = ""
for i=1 to n
dim zNum,zNum2
Randomize
zNum = cint(25*Rnd)
zNum2 = cint(10*Rnd)
if zNum2 mod 2 = 0 then
zNum = zNum + 97
else
zNum = zNum + 65
end if
thechr = thechr & chr(zNum)
next
MyRandc = thechr
end function


function MyRandn(n) ‘生成隨機數(shù)字,n為數(shù)字的個數(shù)
dim thechr
thechr = ""
for i=1 to n
dim zNum,zNum2
Randomize
zNum = cint(9*Rnd)
zNum = zNum + 48
thechr = thechr & chr(zNum)
next
MyRandn = thechr
end function

function formatQueryStr(str) ‘格式化sql中的like字符串
dim nstr
nstr = str
nstr = replace(nstr,chr(0),"")
nstr = replace(nstr,"‘","‘‘")
nstr = replace(nstr,"[","[[]")
nstr = replace(nstr,"%","[%]")
formatQueryStr = nstr
end function

function GetRnd(min,max)
Randomize
GetRnd = Int((max - min + 1) * Rnd + min)
end function

%>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多