| Gzu521.com我的学习网 |
|
/************************************************** * * 9,---------asp+sql 简单的asp类实例 * ******************************************** <% class myclass ’//----声明(声明就是定义)myclass类的类内部(私有的[private])变量 private strauthor private strversion private strexample ’//---------------------------定义类的事件-------------------------------// ’//----class_initialize()是类的初始化事件,只要一开始使用该类,首先会触发该部分的执行,下面我们会 在该成员中初始化该类的作者和版本以及在屏幕上显示一下该类已经开始了 private sub class_initialize() strauthor = "思源" strversion = "1.0" response.write " myclass开始了 " end sub ’//----class_terminate()是类的结束事件,只要一退出该类,就会触发该事件,下面我们会该事件中设定退 出该类时会在屏幕上显示该类已结束了。 private sub class_terminate() response.write " myclass结束了 " end sub ’//---------------------------用户自己定义的方法-------------------------------// ’//----该方法返回一个版本信息 public sub information() response.write " coding by" end sub ’//---------------------------定义类的输出属性-------------------------------// ’//----定类的属性,该属性是让用户初始化strexapmle变量 public property let setexapmle(byval strvar) strexample = strvar ’response.write strexapmle end property ’//---------------------------定义类的输出属性-------------------------------// ’//----定义类的属性,该属性是返回一个版本号 public property get version version = strversion end property ’//----定义类的属性,该属性是返回该类的作者号 public property get author author = strauthor end property ’//----定义类的属性,该属性是返回一个版本号 public property get exapmle exapmle = strexample end property end class ’//-------这里是使用该类的例子 dim onenewclass set onenewclass = new myclass response.write "作者:" & onenewclass.author & " " response.write "版本:" & onenewclass.version & " " onenewclass.setexapmle = "这是一个简单类的例子" response.write "用户自定义:" & onenewclass.exapmle & " " onenewclass.information set onenewclass = nothing %> |
责任编辑:gzu521