精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
返回建站学首页
导航:
建站首页 | 网站设计 | 网站开发 | 网站运营 | 网页软件 | 建站指南 | 搜索优化 | 图像处理 | 视频教程 | 书籍教程 | 建站专题
当前位置:首页>网站开发>ASP教程>正文

在ASP中使用类,实现模块化


来源:不详 时间:07-09-28 点击: 点击这里收藏本文

'-----------------------------------------------------------------
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("<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
9 7 3 1 2 4 8 :

  把此文章收藏到:          
广而告之
文章搜索
  • Google JZxue.Com

关于我们 | 联系我们 | 友情链接 | 网站地图
Copyright © 2005 - 2006 建站学 All rights reserved.