home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Programmer'…arterly (Limited Edition)
/
Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso
/
code
/
ch21code
/
testout.bas
< prev
next >
Wrap
BASIC Source File
|
1995-08-14
|
1KB
|
50 lines
Attribute VB_Name = "Module1"
Option Explicit
' Module-level variable.
Dim Outline As Object
Sub Main()
' Debug code for testing Outline.VBP
' as an OLE server.
#Const DebugBuild = 1
#If DebugBuild Then
Dim strLine As String, strName As String
Set Outline = GetObject("", "Outline.Topic")
Dim Topic As Object
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 If
End Sub
Sub AddLevel(strLine As String, objTopic As Object)
' 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 Object) As Object
Dim Item As Object
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