内容显示页
 
类别:ASP+VBS | 浏览(90) | 2007-7-10 16:06:17

VBS类:

Class Yongfa365Test
    '==========声明变量==========
    Private p1
    Private p2, p3, p4, mySex
    Public MyName 'Public型变量相当于属性,引用类后可以直接调用或设置值
    
    '==========声明属性==========
    Public Property Get Author()
        Author = "http://www.yongfa365.com/"
    End Property

    Public Property Let Sex(Val)
        mySex = Val
    End Property
    
    Public Property Get Sex()
        Sex = mySex
    End Property
    
    '==========声明方法==========

    Public Function WriteSex()
        WriteSex = "我的性别是:" & mySex
    End Function
    
    '==========初 始 化==========

    Private Sub Class_Initialize
        '在创建类的实例时发生此事件。
        '初始化数据:变量,定义一些对象,如Set strm = Server.CreateObject("ADODB.Stream")
        mySex = "女"
    End Sub
    
    '==========销毁对象==========

    Private Sub Class_Terminate
        '在所关联的类的实例终止时发生此事件。
        '把一些对象给注销掉,如:Set strm = Nothing
    End Sub
    
End Class








'创建类的实例。
Set X = New Yongfa365Test 

Str = X.Author
'测试初始化数据
Str = Str + vbCrLf + X.Sex
Str = Str + vbCrLf + X.WriteSex

'测试对属性附值
X.Sex = "男"
Str = Str + vbCrLf + X.Sex
Str = Str + vbCrLf + X.WriteSex

'测试Public变量可以当属性来使
Str = Str + vbCrLf + X.MyName
X.MyName = "我是柳永法"
Str = Str + vbCrLf + X.MyName

MsgBox Str

'销毁类的实例。
Set X = Nothing



可修改代码后再运行
 


vb类

制作方法:

调用方法:

ASP:   set fso=server.createobject("adodb.recordset")

VBS:    set fso=createobject("adodb.recordset")

 

 


引用本页地址:http://www.yongfa365.com/item/VBS-Class-New-CreateObject-VB-DLL.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
专题(3)
 
.Net + C#(41)
 
ASP+VBS(153)
 
 
 
Linux(10)
 
 
 
web 2.0(24)
 
 
 
 
 
心程(59)
 
生活(80)
 
 
     

Power by :柳永法(yongfa365)'Blog | Model by :hibaidu | CSS by:众网友 | 京ICP备07011491号  QQ:64049027  E-mail:64049027qq.com

本空间赞助商:北京中科兴联信息技术有限公司