ASP写类

来源:互联网 发布:备案域名交易 编辑:程序博客网 时间:2024/06/06 17:53

<%
''声明一个名为aspcn的类
Class aspcn
Private aspcn
''初始化类
Private Sub Class_Initialize
aspcn="Aspcn Is Good!<br>"
End Sub
''定义一个函数
Public Function DoIt()
DoIt=aspcn
End Function
''定义一个方法
Public Sub QueryStr(stat)
Response.write stat
End Sub

End Class

Set Hi_aspcn=New aspcn ''定义一个名为Hi_aspcn的aspcn对象实例
response.write Hi_aspcn.DoIt
varstr="Aspcn Is Cool!<br><font color=red>http://www.aspcn.com</font><br>WelCome!!!"
Hi_aspcn.QueryStr varstr

%>


这是很简单的一个程序,我们在其中声明了一个名为aspcn的类,建立了一个DoIt函数,一个QueryStr方法,这个程序很简单相信大家能看懂,它的显示如下:

Aspcn Is Good!
Aspcn Is Cool!
http://www.aspcn.com
WelCome!!!

以后,咱们就可以把我们常用到的程序写成一个类,到时候就用<!--#include file="xxx.asp"-->来包含进来就行了,这给我们开发程序又提供了新的空间,真是爽啊!和C++一样了,有点回归自然的感觉.

原创粉丝点击