Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
5
Добавлен:
26.03.2015
Размер:
2.21 Кб
Скачать
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "NAryNode"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' ************************************************
' NAryNode.CLS
'
' Node class for N-ary tree.
Option Explicit

Public Children As New Collection

Public Box As Label
' ************************************************
' Delete the descendant node. Return True if the
' node is deleted.
' ************************************************
Public Function DeleteDescendant(target As NAryNode) As Boolean
Dim i As Integer
Dim child As NAryNode

' See if it's one of our children.
For i = 1 To Children.Count
If Children.Item(i) Is target Then
Children.Remove i
DeleteDescendant = True
Exit Function
End If
Next i

' It's not one of our children. Recursively
' check the descendants.
For Each child In Children
If child.DeleteDescendant(target) Then
DeleteDescendant = True
Exit Function
End If
Next child
End Function
' ************************************************
' Find the node that corresponds to the Label.
' ************************************************
Public Function FindNode(ctl As Label) As NAryNode
Dim node As NAryNode
Dim child As NAryNode

' See if we are the one.
If ctl = Box Then
Set FindNode = Me
Exit Function
End If

' See if a child can find it.
For Each child In Children
Set node = child.FindNode(ctl)
If Not (node Is Nothing) Then
Set FindNode = node
Exit Function
End If
Next child

Set FindNode = Nothing
End Function

' ************************************************
' Unload the node's label control.
' ************************************************
Private Sub Class_Terminate()
Unload Box
End Sub


Соседние файлы в папке CH6
  • #
    26.03.2015376 б5FSTAR.VBP
  • #
    26.03.20157.96 Кб5NAry.frm
  • #
    26.03.201512 б5NARY.FRX
  • #
    26.03.2015699 б5NARY.VBP
  • #
    26.03.201584 б5NARY.vbw
  • #
    26.03.20152.21 Кб5NAryNode.cls
  • #
    26.03.20159.88 Кб5QTREE.FRM
  • #
    26.03.201512 б5QTREE.FRX
  • #
    26.03.2015415 б5QTREE.VBP
  • #
    26.03.201596 б6QTREE.vbw
  • #
    26.03.201510.15 Кб5QTREE2.BAS