软件教程

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

来源: 本站    类别: 软件教程    日期: 2015/12/7

 这里介绍一下asp类的定义方法和使用方法
1、asp类的定义方法

<%
class myclass
	'这里是定义类的局部变量,需要定义成private类型的变量,不可以直接对这些变量赋值
	private str_title
	private str_author
	
	'这是类初始化的时候自动运行下面代码
	private sub class_initialize()
		response.write "类开始初始化了<br>"
		str_title="一个新页面开始了"
		str_author=""
	end sub
	
	'这里是类结束自动要执行的下面代码
	private sub class_terminate()		
		response.write "类结束了<br>"
	end sub
	
	'这是自定义的函数,如将外面的值赋值给类中的某个值
	public property let setauthor(ByVal str)
		str_author="您赋值的内容是:"&str&""
	end property
	
	'这是获取类中private变量的方法
	public property get author()		
		author=str_author&"<br>"
	end property
	
end class
%>

2、asp类的使用方法
<%
dim a
set a=new myclass 
a.setauthor="www.cnhww.com"
response.write a.author
set a=nothing
%>

 

3、运行的结果:

 类开始初始化了
 您赋值的内容是:www.cnhww.com
 类结束了

相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com