''''----------------------------------------------------------------- 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 bpoint500 Then blevel="初级会员" ElseIf bpoint>=500 And bpoint=100 Then blevel="高级会员" Else blevel="终极会员" End If Getlevel=blevel End Function
我们要得是回送用户的信息,必须定义一个public公用函数,显示信息:
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 消除一些不想要的数字 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("strong style=''''color:red''''>关闭conn连接/strong>...hr/>") End sub ''''----------------------------------------------------------------- Private Sub closers() rs.close Set rs=Nothing response.write("strong style=''''color:#085420''''>关闭数据库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>总数获得了:") 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>显示信息总数:input name="n" type="text" maxlength="4" size="10" />每页数目:input name="pagesize" type="text" maxlength="4" size="10" value="5"/>input name="arrstart" type="hidden" value="0">/label>