超级属性,任意【数据类型】与【对象】通用!
时 间: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群 (群号:483923997) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access窗体导出PDF】...(04.08)
- 【Access窗体导出PDF】...(04.07)
- Access两种方式实现即时更...(03.01)
- Access隐藏与显示lacc...(01.12)
- 【Access高效办公】将每个...(12.23)
- Access21点游戏源代码(12.13)
- 【Access窗体导出Exce...(11.15)
- 【Access开发】Acces...(11.14)
- 通过Access宏录入数据到选...(11.10)
学习心得
最新文章
- Access学习笔记--用Acce...(04.19)
- 【Access重复项查询示例】将A...(04.17)
- Access快速开发平台企业版--...(04.16)
- 【Access模块示例】通过模块代...(04.15)
- Access查询里面分组合计功能添...(04.13)
- 【Access删除查询】删除数字最...(04.12)
- 显示文件夹中所有文件的修改时间(04.11)
- 铁路工程管理系统;铁路工程管理小程...(04.10)
- 【Access查询示例】怎么将两个...(04.09)
- 【Access窗体导出PDF】Ac...(04.08)