asp类的定义方法和使用方法实例

来源:互联网 发布:淘宝人生小说下载 编辑:程序博客网 时间:2024/06/03 16:59
<%02    class myclass03        '这里是定义类的局部变量,需要定义成private类型的变量,不可以直接对这些变量赋值04        private str_title05        private str_author0607        '这是类初始化的时候自动运行下面代码08        private sub class_initialize()09            response.write "类开始初始化了<br>"10            str_title="一个新页面开始了"11            str_author=""12        end sub1314        '这里是类结束自动要执行的下面代码15        private sub class_terminate()      16            response.write "类结束了<br>"17        end sub1819        '这是自定义的函数,如将外面的值赋值给类中的某个值20        public property let setauthor(ByVal str)21            str_author="您赋值的内容是:"&str&""22        end property2324        '这是获取类中private变量的方法25        public property get author()       26            author=str_author&"<br>"27        end property2829    end class30    %>

2、asp类的使用方法
view source
print
?
1
<%
2
dim a
3
set a=new myclass
4
a.setauthor=”www.aspbc.com”
5
response.write a.author
6
set a=nothing
7
%>
3、运行的结果:
1
类开始初始化了
2
您赋值的内容是:www.aspbc.com
3
类结束了

0 0
原创粉丝点击