home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- Option Explicit
- ' Module-level variable.
- Dim Outline As New Topic
-
- Sub Main()
- ' Debug code for testing TOPIC.CLS.
- #Const DebugBuild = 0
- #If DebugBuild Then
- Dim strLine As String, strName As String
- Dim Topic As Topic
- Open "org.txt" For Input As #1
- Do Until EOF(1)
- Line Input #1, strLine
- AddLevel strLine, Outline
- Loop
- Close 1
- strName = InputBox("Enter your name")
- Set Topic = SearchTree(strName, Outline)
- MsgBox "Your boss is " & Topic.Parent.Value
- Set Outline = Nothing
- End
- #End If
- End Sub
-
- Sub AddLevel(strLine As String, objTopic As Topic)
- ' If the line starts with a tab...
- If Mid(strLine, 1, 1) = Chr$(9) Then
- ' Trim off the character and call again.
- AddLevel Right(strLine, Len(strLine) - 1), _
- objTopic.Topics.Item(objTopic.Topics.Count)
- Else
- objTopic.AddSubtopic.Value = strLine
- End If
- End Sub
-
- Function SearchTree(strName As String, objTopic As Topic) As Topic
- Dim Item As Topic
- If objTopic.Topics.Count > 0 Then
- For Each Item In objTopic.Topics
- If Item.Value = strName Then
- Set SearchTree = Item
- Else
- Set SearchTree = SearchTree(strName, Item)
- End If
- Next Item
- End If
- End Function
-