WEB开发网
开发学院WEB开发ASP 常用ASP自定义函数集 (S.Sams) 阅读

常用ASP自定义函数集 (S.Sams)

 2008-10-27 12:06:30 来源:WEB开发网   
核心提示: rem ---生成四位随机数 Being-CODE Copy ...Function get_rand()dim num1dim rndnumRandomizeDo While Len(rndnum)<4num1=CStr(Chr((57-48)*rnd+48))rndnum=rnd

rem ---生成四位随机数 Being-----------------------------

CODE Copy ...

Function get_rand()
dim num1
dim rndnum
Randomize
Do While Len(rndnum)<4
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
get_rand=rndnum
End Function

rem ---判断数据是否整型 Being-----------------------------

CODE Copy ...

Function IsInteger(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
isInteger=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isInteger=false
exit function
end if
l=len(str)
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isInteger=false
exit function
end if
next
isInteger=true
if err.number<>0 then err.clear
End Function

rem ---数据库链接函数 Being-----------------------------

CODE Copy ...

Function OpenCONN
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB_login)
conn.Open connstr
End Function

rem ---中文字符转Uncode代码函数 Being-----------------------------

CODE Copy ...

Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00) &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function

上一页  1 2 3 4 5 6 7  下一页

Tags:常用 ASP 定义

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接