<%
Class xilou
'//-----------------
'Private私有声明的变量是为了在本类内调用,可以初始化供类的方法,属性调用, '在类内用Private Sub Class_Initialize初始化,结束使用后记得要Private Sub Class_Terminate清空;
'在类内对外开放的就只有类的方法和属性,其他都封装起来,只提供方法和属性这些接口,
'当有改动的时候也只要在基类内改动相应的变量等,但对外提供的接口仍然不变,这样符合OOP思想;
'方法用VBS的SUB子过程和FUNCTIONG函数过程实现,访问修饰符要用Public;
'属性用Public Property Let和Public Property Get实现;
'By 西楼冷月 2005-7-26
'//-----------------
Private ver
Private name
Private sex
Private url
'//--初始化变量
Private Sub Class_Initialize
ver="3.0"
name="mm"
sex="female"
url="http://www.xilou.net"
End Sub
'//--结束类后清空变量
Private Sub Class_Terminate
ver=""
name=""
sex=""
url=""
response.write "类结束了~!"
End Sub
'//--方法声明1:用子过程实现
Public Sub GetInfo(ver,name,sex)
dim Str
Str="版本为:"+ver+"<BR/>"+"名字为:"+name+"<BR/>"+"性别为:"+sex+"<BR/>"
response.write Str
End Sub
Public Sub GetInfo001()
dim Str
Str="版本为:"+ver+"<BR/>"+"名字为:"+name+"<BR/>"+"性别为:"+sex+"<BR/>"
response.write Str
End Sub
'//--方法声明2:用函数过程实现
Function geturl()
response.write url
End Function
'//----属性声明
'//----Let和Get后的变量名可以相同可以不相同,用Let声明的调用的是classname.property=""接收值,用Get声明的调用的是classname.property;
'//----一般用response.write classname.property读出他的值
Private getqq
Public Property Let QQ(ByVal qqnum)'可以从外部接收参数
getqq="你的QQ号码是:"+qqnum
End Property
Public Property Get QQID
QQID=getqq
End Property
End Class
%>
<%
dim myclass
set myclass=new xilou
dim a,b,c
a="2.0":b="xilou":c="man"
myclass.GetInfo a,b,c
myclass.GetInfo001
myclass.QQ="39949736"
response.write myclass.QQID+"<BR/>"
myclass.geturl
response.write "<BR/>=========================================<BR/>"
set myclass=nothing
%>