<%
02
class myclass
03
'这里是定义类的局部变量,需要定义成private类型的变量,不可以直接对这些变量赋值
04
private str_title
05
private str_author
06
07
'这是类初始化的时候自动运行下面代码
08
private sub class_initialize()
09
response.write "类开始初始化了<br>"
10
str_title="一个新页面开始了"
11
str_author=""
12
end sub
13
14
'这里是类结束自动要执行的下面代码
15
private sub class_terminate()
16
response.write "类结束了<br>"
17
end sub
18
19
'这是自定义的函数,如将外面的值赋值给类中的某个值
20
public property let setauthor(ByVal str)
21
str_author="您赋值的内容是:"&str&""
22
end property
23
24
'这是获取类中private变量的方法
25
public property get author()
26
author=str_author&"<br>"
27
end property
28
29
end class
30
%>
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
类结束了