''''----------------------------------------------------------------- Property Get getname getname=bname End Property
Property Let getname(nameid) bname=nameid If nameid="" Then bname="沒注冊用戶" End If End Property ''''------------------------------------------------------------------ Property Get getsex getsex=bsex End Property
Property Let getsex(sex) bsex=killint(sex,0,0) If bsex=0 Then bsex="男" Else bsex="女" End if End Property ''''------------------------------------------------------------------ Property Get getpoint getpoint=bpoint End Property
Property Let getpoint(point) bpoint=killint(point,0,0) End Property ''''------------------------------------------------------------------
這里有個killint函數(shù),是判斷數(shù)據(jù)合法性的,它的原形是:
Private Function killint(i,killstr,killsub) If Not IsNumeric(i) Then i=killstr ElseIf i=0 Then i=killsub End if killint=Int(Left(i,5)) End Function
該函數(shù)功能很明確,不再繁瑣說。
由于我們要通過積分判斷用戶級別,這里定義了一個私有函數(shù):
Private Function getlevel() bpoint=killint(bpoint,0,0) If bpoint500 Then blevel="初級會員" ElseIf bpoint>=500 And bpoint=100 Then blevel="高級會員" Else blevel="終極會員" End If Getlevel=blevel End Function
我們要得是回送用戶的信息,必須定義一個public公用函數(shù),顯示信息:
Public Function showuser() response.write("h5>以下顯示font color=red>"bname"/font>的資料:/h5>") response.write("h5>性別:font color=red>"bsex"/font>/h5>") response.write("h5>積分:font color=red>"bpoint"/font>/h5>") getlevel response.write("h5>級別:font color=red>"blevel"/font>/h5>") End Function End class
使用這個類的時候這樣使用:(我在這里寫了一個表單處理的)
Set blueideauser=new blueidea blueideauser.getname=Trim(request("id")) blueideauser.getsex=request("sex") blueideauser.getpoint=request("point") blueideauser.showuser
''''------------------------------------------------------------------ rem 消除一些不想要的數(shù)字 Private Function litter_in(r1,r2) If IsNumeric(r1) and IsNumeric(r2) Then Dim dimrr If r1>r2 Then dimrr=r2 Else dimrr=r1 End If Else dimrr=0 End if litter_in=dimrr End Function ''''----------------------------------------------------------------- Private Function killint(i,killstr,killsub) If Not IsNumeric(i) Then i=killstr ElseIf i=0 Then i=killsub End if killint=Int(Left(i,5)) End Function ''''----------------------------------------------------------- private Sub startconn() On Error Resume Next Set conn=server.CreateObject("adodb.connection") strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" Server.MapPath(sqlstr) conn.open strconn If Err Then err.Clear Set Conn = Nothing mess="發(fā)生錯誤,不能連接數(shù)據(jù)庫" response.write(mess) response.End Else mess="連接數(shù)據(jù)庫conn成功........... " response.write(mess) End If End Sub ''''---------------------------------------------------------------- private Sub closeconn() conn.close Set conn=Nothing response.write("strong style=''''color:red''''>關(guān)閉conn連接/strong>...hr/>") End sub ''''----------------------------------------------------------------- Private Sub closers() rs.close Set rs=Nothing response.write("strong style=''''color:#085420''''>關(guān)閉數(shù)據(jù)庫RS/strong>....... ")
End Sub
''''----------------------------------------------------------------- Property Get havese havese=isession End Property
Property Let havese(yoursession) isession=yoursession If yoursession="" Then isession="nodef" End If End Property
''''----------------------------------------------------------------- Public Function makesession(arraydata) If IsArray(arraydata) then makear=arraydata Else makear=Array(0,0,0,0) End If If isession="" Then isession="nodef" End if session(isession)=makear End Function ''''-----------------------------------------------------------------
private Function getsession() thisget=session(isession) If Not IsArray(thisget) Then thisget=Array(0,0,0,0) End If Getsession=thisget End function ''''----------------------------------------------------------------- Property Get ConnectString ConnectString = sqlstr End Property Property Let ConnectString(str) sqlstr = str End Property ''''-----------------------------------------------------------------
Property Get getid getid = iid End Property Property Let getid(id) iid = id End Property ''''-----------------------------------------------------------------
Property Get gettable gettable = itable End Property Property Let gettable(table) itable = table End Property ''''----------------------------------------------------------------- ''''------------------------------------------------------------------ public Function readarraysession(iStart,ipageno,irowid) rowid=killint(irowid,0,0) start=killint(istart,0,0) pageno=killint(ipageno,5,5) data=getsession iRows = UBound(data, 2) iCols = UBound(data, 1) response.write("h5>總數(shù)獲得了:") response.write("b> "iRows+1"/b>條信息/h5>hr/>ul style=''''width:100%;''''>") If rowid = 0 then If iRows > (ipageno + iStart) Then iStop = ipageno + iStart - 1 Else iStop = iRows End If For iRowLoop = Start to iStop Response.Write ("li style=''''padding:4px 0;''''>a href=?k=readrowid="irowloop+1">"data(1, iRowLoop) " /a>span style=''''padding:4px 0 4px 10px;background-color:#ccc; ''''>較慢,不推薦點擊-->a href=?k=listid="data(0,irowloop)">更新/a>/span>/li>") Next Response.Write "/ul>div style=''''top:20px;background-color:#ccc;color:#020;font-weight:bold;bordr-top:2px solid #008;padding:10px 0;color:#b00''''>列表(a href=default.asp>回到典型模式/a>):" if Start > 0 then Response.Write "A HREF=""?k=readStart=" iStart-ipageno "pageno=" ipageno """>Previous/A>" end if if iStop iRows then Response.Write " A HREF=""?k=readStart=" iStart+ipageno "pageno=" ipageno """>Next/A>" end If
response.write"/div>"
Else rowid=litter_in(rowid-1,iRows) response.write("div style=''''width:85%''''>h4 style=''''text-align:center''''>a href=?k=readpageno="pageno"start="start">返回列表/a>/h4>/h2>hr/>h5>"server.htmlencode(data(1,rowid))"/h5>p>"server.htmlencode(data(2,rowid))"h5>+-----"server.htmlencode(data(3,rowid))"") response.write("div >") End if End Function
''''----------------------------------------------------------------- Public Function list_ids() sql3="select * from "itable" where id="iid" " startconn() Set rs=conn.execute(sql3) If rs.eof And rs.bof Then data=Array(0,0,0,0) Else data=Rs.GetRows() End If closers closeconn response.write(UBound(data)":") response.write(server.htmlencode(data(2,0))) End function
''''----------------------------------------------------------------- Public Function rs_top(num,table,whe) startconn() sql="select top "num" * from "table"" sql2="select count(*) as szd_count from "table" "" "whe"" Set rs=conn.execute(sql2) szd_count=rs("szd_count") closers Set rs = Conn.Execute(sql) dim data If Rs.Eof Then data="no data" Else data=Rs.GetRows() End if closers closeconn() Call makesession (data) End Function ''''+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ End Class
試用方法: Dim action action=request("k") If action="view" Then Call viewnew ElseIf action="list" Then Call list() ElseIf action="read" Then Call read() Else Call ff() End if Sub ff() %> form style="border-top:2px solid #008;border-bottom:2px solid #008;margin:auto;background-color:#eee;padding:20px 5px;color:#008;font-weight:bold;"> label>顯示信息總數(shù):input name="n" type="text" maxlength="4" size="10" />每頁數(shù)目:input name="pagesize" type="text" maxlength="4" size="10" value="5"/>input name="arrstart" type="hidden" value="0">/label>