Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
5
Добавлен:
26.03.2015
Размер:
2.71 Кб
Скачать
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "SortNode"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
' ************************************************
' SortNode.CLS
'
' Node class for sorted tree example program.
' ************************************************
' Copyright (C) 1997 John Wiley & Sons, Inc.
' All rights reserved. See additional copyright
' information in RIGHTS.TXT.
' ************************************************
Option Explicit

Public LeftChild As SortNode
Public RightChild As SortNode
Public Value As Integer

Public Box As Label
' ************************************************
' Delete the descendant node. Return True if the
' node is deleted.
' ************************************************
Public Function DeleteDescendant(target As SortNode) As Boolean
If LeftChild Is target Then
Set LeftChild = Nothing
DeleteDescendant = True
Exit Function
End If
If RightChild Is target Then
Set RightChild = Nothing
DeleteDescendant = True
Exit Function
End If

' It's not one of our children. Recursively
' check the descendants.
If Not (LeftChild Is Nothing) Then
If LeftChild.DeleteDescendant(target) Then
DeleteDescendant = True
Exit Function
End If
End If
If Not (RightChild Is Nothing) Then
If RightChild.DeleteDescendant(target) Then
DeleteDescendant = True
Exit Function
End If
End If
End Function
' ************************************************
' Find the node that corresponds to the Label.
' ************************************************
Public Function FindNode(ctl As Label) As SortNode
Dim node As SortNode

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

' See if the left child is the one.
If Not LeftChild Is Nothing Then
Set node = LeftChild.FindNode(ctl)
If Not (node Is Nothing) Then
Set FindNode = node
Exit Function
End If
End If

' See if the right child is the one.
If Not (RightChild Is Nothing) Then
Set node = RightChild.FindNode(ctl)
If Not (node Is Nothing) Then
Set FindNode = node
Exit Function
End If
End If

Set FindNode = Nothing
End Function

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


Соседние файлы в папке CH6
  • #
    26.03.20159.5 Кб6QTREE2.FRM
  • #
    26.03.201512 б5QTREE2.FRX
  • #
    26.03.2015388 б5QTREE2.VBP
  • #
    26.03.2015546 б6QTRITEM.CLS
  • #
    26.03.20156.73 Кб6QTRNODE.CLS
  • #
    26.03.20152.71 Кб5SORTNODE.CLS
  • #
    26.03.201511.6 Кб5Trav1.frm
  • #
    26.03.201512 б5TRAV1.FRX
  • #
    26.03.2015596 б5TRAV1.VBP
  • #
    26.03.201556 б5TRAV1.vbw
  • #
    26.03.201512.62 Кб5Trav2.frm