''''----------------------------------------------------------------- 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函数,是判断数据合法性的,它的原形是:
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 Function getlevel() bpoint=killint(bpoint,0,0) If bpoint<500 Then blevel="初级会员" ElseIf bpoint>=500 And bpoint<=100 Then blevel="高级会员" Else blevel="终极会员" End If Getlevel=blevel End Function
我们要得是回送用户的信息,必须定义一个public公用函数,显示信息:
Public Function showuser() response.write("
以下显示"&bname&"的资料:
") response.write("
性别:"&bsex&"
") response.write("
积分:"&bpoint&"
") getlevel response.write("
级别:"&blevel&"
") End Function End class
使用这个类的时候这样使用:(我在这里写了一个表单处理的)
Set blueideauser=new blueidea blueideauser.getname=Trim(request("id")) blueideauser.getsex=request("sex") blueideauser.getpoint=request("point") blueideauser.showuser
''''------------------------------------------------------------------ rem 消除一些不想要的数字 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="发生错误,不能连接数据库" response.write(mess) response.End Else mess="连接数据库conn成功........... " response.write(mess) End If End Sub ''''---------------------------------------------------------------- private Sub closeconn() conn.close Set cOnn=Nothing response.write("关闭conn连接...") End sub ''''----------------------------------------------------------------- Private Sub closers() rs.close Set rs=Nothing response.write("关闭数据库RS....... ")
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("
总数获得了:") response.write(" "&iRows+1&"条信息
") 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 ("
''''----------------------------------------------------------------- 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() %>
操作:
<%End sub%> <%Sub viewnew() f_num=killint(request("n"),1,1) pagesize=killint(request("pageno"),5,5) arrstart=killint(request("start"),0,0) rowid=killint(request("rowid"),0,0) Set cs=new ado_5do8 cs.COnnectString="data/a.mdb" cs.havese="shi" cs.rs_top f_num,"site_szd","" cs.readarraysession arrstart,pagesize,rowid End sub Sub list() response.write("
") response.write"下面显示具体信息:" id=request("id") id=killint(id,1,1) Set listid=new ado_5do8 listid.COnnectString="data/a.mdb" listid.getid=id listid.gettable="site_szd" listid.list_ids() End Sub