簡單asp類模仿

來源:互聯網
上載者:User
現在才發現asp裡面也可以自己寫一些類,而且基本上和其他語言差不多,所以就自己寫了一個試試,嘿嘿!紀年一下!
<%
Class clsDSJ
Private p_Error,p_Author,p_WebURL

Public Property Get Version
Version="DSJ 1.0.0 Beta"
End Property

Public Property Get Error
Error=p_Error
End Property

Public Property Get Author
Author=p_Author
End Property

Public Property Let Author(strAuthor)
strAuthor=Trim(strAuthor)
If strAuthor="" Then
p_Author="孤劍"
Else
p_Author=CStr(strAuthor)
End If
End Property

Public Property Get WebURL
WebURL=p_WebURL
End Property

Public Property Let WebURL(URL)
URL=Trim(URL)
If URL="" Then
p_WebURL="http://www.blog.csdn.net/alonesword/"
ELse
If LCase(CStr(Left(URL,7)))<>"http://" then
p_WebURL="http://" & URL
Else
p_WebURL=URL
End If
End If
End Property

Private Sub Class_Initialize
p_Author="孤劍"
WebURL="http://www.blog.csdn.net/alonesword/"
p_Error=-1


End Sub

Private Sub Class_Terminate

End Sub

Public Function gotTopic(str,strlen)
Rem 限制字串顯示長度在一定的範圍內
Dim i,StringLen,CharSize,EchoCharType
StringLen=len(str)
CharSize=0
For i=1 to StringLen
EchoCharType=Abs(Asc(Mid(str,i,1)))
If EchoCharType>255 Then
CharSize=CharSize+2
Else
CharSize=CharSize+1
End If
If CharSize>strlen Then
gotTopic=Left(str,i) & "..."
Exit For
Else
gotTopic=str & ""
End If
Next
End Function

'******************************
'名稱: ChkInvaildWords
'參數:Words
'傳回值:True/Falsh
'作用:檢查參數是否有非法字元
'******************************
Function ChkWords(Words)
Rem 定義需要過濾得非法字元
Const InvaildWords="select|update|delete|insert|@|--|,|'|#|%"
ChkWords=True
InvaildWord=Split(InvaildWords,"|")
inWords=LCase(Trim(Words))

For i=LBound(InvaildWord) To UBound(InvaildWord)
If Instr(inWords,InvaildWord(i))>0 Then
p_Error=0
ChkWords=False
Exit Function
End If
Next
ChkWords=True
End Function

Function DividedPage(objRs,perPageSize,CurrentPage)
objRs.Pagesize=perPageSize
TotalPage=objRs.PageCount

If IsEmpty(perPageSize) Or IsEmpty(CurrentPage) Then
p_Error=1
Response.Write("<Font style='font-size:12px;'>參數不可為空!<br></Font>")
Response.End()
Exit Function
ElseIf (IsNumeric(perPageSize)=false Or IsNumeric(CurrentPage)=false) then
p_Error=2
Response.Write("<Font style='font-size:12px;'>參數不可為空!<br></Font>")
Response.End()
Exit Function
End If

If CLng(CurrentPage)<1 Then CurrentPage=1 End If
If CLng(CurrentPage)>TotalPage Then CurrentPage=TotalPage End If

If TotalPage>0 Then
objRs.AbsolutePage=CurrentPage
End If

Items=1
Do While Not objRs.Eof
Response.Write(Items)
objRs.MoveNext
Loop
End Function '終止於2004年11月27日

End Class

Dim DSJ
Set DSJ=New clsDSJ
%>



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.