超级属性,任意【数据类型】与【对象】通用!
时 间:2020-07-06 08:25:08
作 者:litao ID:37995 城市:上海
摘 要:给【类模块】添加一个超级属性,能任意扩展、改变!
一次添加,一次爽!
这次添加,无穷爽!
正 文:
但是,很多时候很尴尬,经常性的要去修改旧有的类,增加或改变【类】的属性。当程序越写越大的时候,改变一个常用的【类】,将是一个非常巨大的工程。
考虑很久,我给我写的【类模块】加上一个万用的属性,随时可以扩展、修改。
它以一个词典为基础,添加一个Develop属性,具备任意扩展性! 属性值支持任意数据类型或对象。
--------------------代码---------------------------
Private DevelopDic_ As Scripting.Dictionary '扩展属性词典
Public Property Get Develop_Exists(Key As String) As Boolean '验证扩展属性是否存在
If DevelopDic_ Is Nothing Then Set DevelopDic_ = New Scripting.Dictionary
Develop_Exists = DevelopDic_.Exists(Key)
End Property
Public Property Get Develop(Key As String) '获取扩展属性
If Me.Develop_Exists(Key) = False Then GoTo Err1
On Error GoTo Next1
Set Develop = DevelopDic_.Item(Key)
Exit Property
Next1:
On Error GoTo Next2
Develop = DevelopDic_.Item(Key)
Exit Property
Next2:
On Error GoTo Err1
Develop = Null
Err1:
End Property
Public Property Let Develop(Key As String, Val As Variant) '属性赋值
If DevelopDic_ Is Nothing Then Set DevelopDic_ = New Scripting.Dictionary
DevelopDic_.Item(Key) = Val
End Property
Public Property Set Develop(Key As String, Obj As Object) '设置对象引用
If DevelopDic_ Is Nothing Then Set DevelopDic_ = New Scripting.Dictionary
Set DevelopDic_.Item(Key) = Obj
End Property
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access选项卡示例】Ac...(09.09)
- 【Access源码示例】按输入...(09.02)
- 【Access日期区间段查询】...(08.29)
- 【Access日期区间段查询】...(08.27)
- Access怎样才能实现日期时...(08.21)
- 【Access定时打开查询】A...(08.19)
- Access生成固定数量的记录...(08.13)
- Access怎样才能实现日期时...(08.12)
- Access利用导航窗体控件对...(08.03)
学习心得
最新文章
- Access表中的字段名、字段标题...(09.19)
- Access快速开发平台--更改“...(09.18)
- 【中秋及国庆优惠】Access培训...(09.15)
- Access如何将日期型的数值转换...(09.14)
- 英文输入法输入数据中存在单引号引起...(09.11)
- 【Access选项卡示例】Acce...(09.09)
- 让Access光标停留在指定的控件...(09.07)
- 关于Access查询条件里使用通配...(09.06)
- Access报表偷懒制作法--Ac...(09.05)
- Access快速开发平台--窗体数...(09.04)