|
楼主 |
发表于 2021-4-25 16:05
|
显示全部楼层
本帖最后由 山中老人 于 2021-4-27 07:11 编辑
教程3 Object 与 Value
接前面,我们的树结构搭建好了,现在可以在上面挂东西了(存取数据)!
第一步:通过 Object 我们可以给任何Branch挂上一些果子(对象)。
Dim TD As New TreeDic
Dim whq As TreeDic: Set whq = TD.PathBranch("/中国/四川/成都/武侯区", , True) '依据字符串,创建结构
Dim RS As New ADODB.Recordset
Set whq.Object("数据集") = RS
Set RS = whq.Object("数据集")
TreeDic.Object 的声明:可读写
Public Property Get Object (Key As Variant) As Object '对象
Public Property Set Object (Key As Variant, RHS As Object) '对象
TreeDic与Object 相关的属性和方法:
Public Function ObjectExist(Key As Variant) As Boolean '确定对象是否存在
Public Property Get ObjectCount() As Long '对象计数
Public Property Get Objects() As TreeDic() '获得对象的数组
Public Function ObjectRemove(Key As Variant) As Boolean '移除一个对象
Public Sub ObjectRemoveAll() '移除全部对象
第二步:通过 Value我们可以给任何Branch挂上一些树叶(值)。
Dim TD As New TreeDic
Dim Brc As TreeDic : Set Brc = TD("中国")("四川")("成都")("武侯区")
Brc.Value("面积") = 76.99
Debug.Print Brc .ValueStr("面积")
输出:
/中国/四川/成都/武侯区.面积=76.99
TreeDic.Value的声明:可读写
Public Property Get Value(Key As Variant) As Object '值
Public Property Let Value(Key As Variant, RHS As Object) '值
TreeDic与Value相关的属性和方法:
Public Function ValueExist(Key As Variant) As Boolean '确定值是否存在
Public Property Get ValueCount() As Long '值计数
Public Property Get Values() As TreeDic() '获得值的数组
Public Function ValueRemove(Key As Variant) As Boolean '移除一个值
Public Sub ValueRemoveAll() '移除全部值
Public Function ValueStr(ByVal Key As Variant) As String '值的(带路径)表达式 见:【教程5 文本导入导出】
副本Xl0000092.rar
(75.76 KB, 下载次数: 56)
|
评分
-
2
查看全部评分
-
|