home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form GlobeForm
- Appearance = 0 'Flat
- BackColor = &H80000000&
- Caption = "TreeView Demo (with unique keys)"
- ClientHeight = 6630
- ClientLeft = 165
- ClientTop = 735
- ClientWidth = 8430
- LinkTopic = "Form1"
- ScaleHeight = 6630
- ScaleWidth = 8430
- StartUpPosition = 3 'Windows Default
- Begin VB.Frame Frame2
- Height = 6480
- Left = 5280
- TabIndex = 8
- Top = 0
- Width = 3015
- Begin VB.ListBox List1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 3210
- Left = 165
- TabIndex = 13
- Top = 240
- Width = 2715
- End
- Begin VB.CommandButton ListCities
- Caption = "List Cities"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 165
- TabIndex = 12
- Top = 5730
- Width = 2715
- End
- Begin VB.CommandButton ListContinents
- Caption = "List Continents"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 165
- TabIndex = 11
- Top = 4455
- Width = 2715
- End
- Begin VB.CommandButton ListCountries
- Caption = "List Countries"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 165
- TabIndex = 10
- Top = 5100
- Width = 2715
- End
- Begin VB.CommandButton FindCity
- Caption = "Find City"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 165
- TabIndex = 9
- Top = 3855
- Width = 2715
- End
- End
- Begin VB.CommandButton ExpandNodeBttn
- Caption = "Expand Current Node"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 2655
- TabIndex = 7
- Top = 3540
- Width = 2400
- End
- Begin VB.CommandButton DeleteNodeBttn
- Caption = "Delete Current Node"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 180
- TabIndex = 6
- Top = 3540
- Width = 2400
- End
- Begin VB.CommandButton AddEntry
- Caption = "Add this Node"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 2880
- TabIndex = 4
- Top = 5850
- Width = 2055
- End
- Begin VB.TextBox Text3
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 2850
- TabIndex = 3
- Top = 5250
- Width = 2055
- End
- Begin VB.TextBox Text2
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 1665
- TabIndex = 2
- Top = 4815
- Width = 2055
- End
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 345
- TabIndex = 1
- Top = 4365
- Width = 2055
- End
- Begin ComctlLib.TreeView TreeView1
- Height = 3255
- Left = 165
- TabIndex = 0
- Top = 165
- Width = 4890
- _ExtentX = 8625
- _ExtentY = 5741
- _Version = 393217
- HideSelection = 0 'False
- LabelEdit = 1
- Sorted = -1 'True
- Style = 6
- HotTracking = -1 'True
- Appearance = 1
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- _Nodes = "TView.frx":0000
- End
- Begin VB.Frame Frame1
- Height = 2430
- Left = 150
- TabIndex = 5
- Top = 4050
- Width = 4965
- Begin VB.Line Line1
- X1 = 375
- X2 = 375
- Y1 = 675
- Y2 = 1350
- End
- Begin VB.Line Line2
- X1 = 1530
- X2 = 375
- Y1 = 900
- Y2 = 900
- End
- Begin VB.Line Line4
- X1 = 2715
- X2 = 360
- Y1 = 1350
- Y2 = 1350
- End
- End
- Begin ComctlLib.ImageList ImageList1
- Left = -15
- Top = 3705
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 32
- ImageHeight = 32
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 5
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "TView.frx":0028
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "TView.frx":047C
- Key = "Snow"
- Object.Tag = "Weather"
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "TView.frx":08D0
- Key = ""
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "TView.frx":0D24
- Key = ""
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "TView.frx":1178
- Key = ""
- EndProperty
- EndProperty
- End
- Begin VB.Menu FileMenu
- Caption = "File"
- Begin VB.Menu FileLoad
- Caption = "Load Control"
- End
- Begin VB.Menu FileSave
- Caption = "Save Control"
- End
- Begin VB.Menu sep1
- Caption = "-"
- End
- Begin VB.Menu FileExit
- Caption = "Exit"
- End
- End
- Attribute VB_Name = "GlobeForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Option Explicit
- Private Sub AddEntry_Click()
- Dim newNode As Node
- Dim NodeContinent As Node, NodeCountry As Node, NodeCity As Node
- On Error Resume Next
- Text1.Text = Trim(Text1.Text)
- Text2.Text = Trim(Text2.Text)
- Text3.Text = Trim(Text3.Text)
- If Trim(Text1.Text) = "" Then
- MsgBox "You didn't supply a continent name"
- Exit Sub
- End If
- Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text))
- If Error Then
- Set newNode = TreeView1.Nodes.Add("GLOBE", tvwChild, UCase$(Text1.Text), Text1.Text, 2)
- newNode.Tag = "Continents"
- End If
- If Trim(Text2.Text) = "" Then Exit Sub
- Set newNode = TreeView1.Nodes.Item(UCase$(Text2.Text))
- If Error Then
- Set newNode = TreeView1.Nodes.Add(UCase$(Text1.Text), tvwChild, UCase$(Text2.Text), Text2.Text, 3)
- newNode.Tag = "Countries"
- End If
- If Trim(Text3.Text) = "" Then Exit Sub
- Set newNode = TreeView1.Nodes.Item(UCase$(Text3.Text))
- If Error Then
- Set newNode = TreeView1.Nodes.Add(UCase$(Text2.Text), tvwChild, UCase$(Text3.Text), Text3.Text)
- newNode.Tag = "Cities"
- End If
- TreeView1.SelectedItem = newNode
- TreeView1.SelectedItem.EnsureVisible
- End Sub
- Private Sub DeleteNodeBttn_Click()
- TreeView1.Nodes.Remove (TreeView1.SelectedItem.Index)
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- End Sub
- Private Sub ExpandNodeBttn_Click()
- TreeView1.SelectedItem.Expanded = True
- End Sub
- Private Sub FileExit_Click()
- End
- End Sub
- Private Sub FileLoad_Click()
- Dim FNum As Integer
- Dim Nd As Node
- Dim level1 As String, level2 As String
- Dim key As String
- Dim nodeText As String
- TreeView1.Nodes.Clear
- ' set up the ListImage object
- Dim Images As ListImage
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\cont.bmp"))
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\country.bmp"))
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\city.bmp"))
- TreeView1.ImageList = ImageList1
- ' THERE'S NO NEED TO DO ANYTHING ABOUT SORTING KEYS, BECAUSE
- ' THE ITEMS WERE SORTED WHEN THE TREEVIEW CONTROL WAS SAVED
- FNum = FreeFile()
- Set Nd = TreeView1.Nodes.Add(, , "GLOBE", "Globe", 1)
- Nd.Tag = "GLOBE"
- Nd.Sorted = True
- Open App.Path & "\Globe.txt" For Input As #FNum
- While Not EOF(FNum)
- Input #FNum, nodeText
- key = UCase(Trim(nodeText))
- If Left(nodeText, 3) = " " Then
- Set Nd = TreeView1.Nodes.Add(level2, tvwChild, key, Trim(nodeText), 3)
- Nd.Tag = "Cities"
- ElseIf Left(nodeText, 2) = " " Then
- level2 = key
- Set Nd = TreeView1.Nodes.Add(level1, tvwChild, key, Trim(nodeText), 2)
- Nd.Tag = "Countries"
- ElseIf Left(nodeText, 1) = " " Then
- level1 = key
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, key, Trim(nodeText), 1)
- Nd.Tag = "Continents"
- End If
- Wend
- Close #FNum
- End Sub
- Private Sub FileSave_Click()
- Dim Nd As Node, countryNd As Node, continentNd As Node, cityNd As Node
- Dim continent As Integer, continents As Integer
- Dim country As Integer, countries As Integer
- Dim city As Integer, cities As Integer
- Dim FNum As Integer
- FNum = FreeFile()
- Open App.Path & "\Globe.txt" For Output As #FNum
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- Debug.Print Nd.Text
- Write #FNum, Nd.Text
- continents = Nd.Children
- Set continentNd = Nd.Child
- For continent = 1 To continents
- Debug.Print continentNd.Text
- Write #FNum, " " & continentNd.Text
- countries = continentNd.Children
- Set countryNd = continentNd.Child
- For country = 1 To countries
- Debug.Print " " & countryNd.Text
- Write #FNum, " " & countryNd.Text
- cities = countryNd.Children
- Set cityNd = countryNd.Child
- For city = 1 To cities
- Debug.Print " " & cityNd.Text
- Write #FNum, " " & cityNd.Text
- Set cityNd = cityNd.Next
- Next
- Set countryNd = countryNd.Next
- Next
- Set continentNd = continentNd.Next
- Next
- Close #FNum
- End Sub
- Private Sub FindCity_Click()
- Dim Nd As Node, ParentNd As Node
- Dim NodeName As String, NodeKey As String
- On Error GoTo NoCity
- NodeName = InputBox("Enter name of node")
- NodeKey = UCase$(Trim(NodeName))
- Set Nd = TreeView1.Nodes.Item(NodeKey)
- TreeView1.SelectedItem = Nd
- Set ParentNd = Nd.Parent
- If Not IsNull(ParentNd) Then
- NodeKey = UCase$(ParentNd.Text)
- TreeView1.Nodes(NodeKey).Expanded = True
- End If
- Set ParentNd = ParentNd.Parent
- If Not IsNull(ParentNd) Then
- NodeKey = UCase$(ParentNd.Text)
- TreeView1.Nodes(NodeKey).Expanded = True
- End If
- Set ParentNd = ParentNd.Parent
- If Not IsNull(ParentNd) Then
- NodeKey = UCase$(ParentNd.Text)
- TreeView1.Nodes(NodeKey).Expanded = True
- End If
- Text3.Text = TreeView1.SelectedItem.Text
- Text2.Text = TreeView1.SelectedItem.Parent.Text
- Text1.Text = TreeView1.SelectedItem.Parent.Parent.Text
- Exit Sub
- NoCity:
- If Err.Number = 35601 Then
- MsgBox "The city you requested does not exist"
- Else
- MsgBox "The key you supplied is not a city name"
- End If
- End Sub
- Private Sub Form_Load()
- Dim Nd As Node
- ' set up the ListImage object
- ImageList1.ListImages.Add , , LoadPicture(App.Path & "\cont.bmp")
- ImageList1.ListImages.Add , , LoadPicture(App.Path & "\country.bmp")
- ImageList1.ListImages.Add , , LoadPicture(App.Path & "\city.bmp")
- TreeView1.ImageList = ImageList1
- ' now set up Treeview control
- Set Nd = TreeView1.Nodes.Add(, , "GLOBE", "Globe", 1)
- Nd.Tag = "GLOBE"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "EUROPE", "EUROPE", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' this statement sorts all countries under EUROPE
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "ASIA", "ASIA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' this statement sorts all countries under ASIA
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "AFRICA", "AFRICA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' ' this statement sorts all countries under AFRICA
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "AMERICA", "AMERICA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' this statement sorts all countries under AMERICA
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "OCEANIA", "OCEANIA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "GERMANY", "Germany", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all german cities
- Set Nd = TreeView1.Nodes.Add("GERMANY", tvwChild, "BERLIN", "Berlin")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("GERMANY", tvwChild, "MUNICH", "Munich")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("GERMANY", tvwChild, "BAYREUTH", "Bayreuth")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("GERMANY", tvwChild, "FRANFURT", "Frankfurt")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "FRANCE", "France", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all french cities
- Set Nd = TreeView1.Nodes.Add("FRANCE", tvwChild, "PARIS", "Paris")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("FRANCE", tvwChild, "NICE", "Nice")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("FRANCE", tvwChild, "LYON", "Lyon")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "ITALY", "Italy", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all italian cities
- Set Nd = TreeView1.Nodes.Add("ITALY", tvwChild, "ROME", "Rome")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ITALY", tvwChild, "VENICE", "Venice")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ITALY", tvwChild, "NAPOLI", "Napoli")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ITALY", tvwChild, "FLORENCE", "Florence")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ITALY", tvwChild, "MILAN", "Milan")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "SPAIN", "Spain", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all spanish cities
- Set Nd = TreeView1.Nodes.Add("SPAIN", tvwChild, "MADRID", "Madrid")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("SPAIN", tvwChild, "BARCELONA", "Barcelona")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("SPAIN", tvwChild, "MALAGA", "Malaga")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ASIA", tvwChild, "CHINA", "China", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("CHINA", tvwChild, "BEJING", "Bejing")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("CHINA", tvwChild, "NANJING", "Nanjing")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("CHINA", tvwChild, "HONG KONG", "Hong Kong")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ASIA", tvwChild, "JAPAN", "Japan", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("JAPAN", tvwChild, "TOKYO", "Tokyo")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("JAPAN", tvwChild, "OSAKA", "Osaka")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("JAPAN", tvwChild, "KOBE", "Kobe")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("JAPAN", tvwChild, "KYOTTO", "Kyotto")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("JAPAN", tvwChild, "SAPPORO", "Sapporo")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "EGYPT", "Egypt", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("EGYPT", tvwChild, "CAIRO", "Cairo")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EGYPT", tvwChild, "ALEXANDRIA", "Alexandria")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "LIBYA", "Libya", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("LIBYA", tvwChild, "TRIPOLI", "Tripoli")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "SOUTH AFRICA", "South Africa", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("SOUTH AFRICA", tvwChild, "JOHANNESBURG", "Johannesburg")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("SOUTH AFRICA", tvwChild, "PRETORIA", "Pretoria")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "ZIMBABWE", "Zimbabwe", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("ZIMBABWE", tvwChild, "HARARE", "Harare")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA", tvwChild, "AUSTRALIA", "Australia", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AUSTRALIA", tvwChild, "SINDEY", "Sidney")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AUSTRALIA", tvwChild, "MELBOURNE", "Melbourne")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AUSTRALIA", tvwChild, "ADELAIADE", "Adelaida")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AUSTRALIA", tvwChild, "BRISBANE", "Brisbane")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AUSTRALIA", tvwChild, "CANBERRA", "Canberra")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA", tvwChild, "NEW ZEALAND", "New Zealand", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("NEW ZEALAND", tvwChild, "WANAKA", "Wanaka")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "USA", "USA", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("USA", tvwChild, "NEW YORK", "New York")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("USA", tvwChild, "LAS VEGAS", "Las Vegas")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("USA", tvwChild, "CHICAGO", "Chicago")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("USA", tvwChild, "WASHINGTON", "Washington")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("USA", tvwChild, "DURHAM", "Durham")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("USA", tvwChild, "SAN FRANCISCO", "San Francisco")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "CANADA", "Canada", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("CANADA", tvwChild, "TORONTO", "Toronto")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("CANADA", tvwChild, "VANCOUVER", "Vancouver")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("CANADA", tvwChild, "MONTREAL", "Montreal")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("CANADA", tvwChild, "HALIFAX", "Halifax")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("CANADA", tvwChild, "CALGARY", "Calgary")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "MEXICO", "Mexico", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("MEXICO", tvwChild, "MEXICO CITY", "Mexico City")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "ARGENTINA", "Argentina", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("ARGENTINA", tvwChild, "BUENOS AIRES", "Buenos Aires")
- Nd.Tag = "Cities"
- End Sub
- Private Sub ListCities_Click()
- Dim Nd As Node, countryNd As Node, continentNd As Node, cityNd As Node
- Dim continent As Integer, continents As Integer
- Dim country As Integer, countries As Integer
- Dim city As Integer, cities As Integer
- List1.Clear
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- continents = Nd.Children
- Set continentNd = Nd.Child
- For continent = 1 To continents
- countries = continentNd.Children
- Set countryNd = continentNd.Child
- For country = 1 To countries
- cities = countryNd.Children
- Set cityNd = countryNd.Child
- For city = 1 To cities
- List1.AddItem cityNd.Text
- Set cityNd = cityNd.Next
- Next
- Set countryNd = countryNd.Next
- Next
- Set continentNd = continentNd.Next
- Next
- End Sub
- Private Sub ListContinents_Click()
- Dim Nd As Node, childNd As Node
- Dim continent As Integer, continents As Integer
- List1.Clear
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- continents = Nd.Children
- Set childNd = Nd.Child
- For continent = 1 To continents
- List1.AddItem childNd.Text
- Set childNd = childNd.Next
- Next
- End Sub
- Private Sub ListCountries_Click()
- Dim Nd As Node, countryNd As Node, continentNd As Node
- Dim continent As Integer, continents As Integer
- Dim country As Integer, countries As Integer
- List1.Clear
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- continents = Nd.Children
- Set continentNd = Nd.Child
- For continent = 1 To continents
- countries = continentNd.Children
- Set countryNd = continentNd.Child
- For country = 1 To countries
- List1.AddItem countryNd.Text
- Set countryNd = countryNd.Next
- Next
- Set continentNd = continentNd.Next
- Next
- End Sub
- Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
- Dim Nd As Node, childNd As Node
- Dim i As Integer
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- Set Nd = Node
- Me.Caption = Nd.FullPath
- Nd.Expanded = Not Nd.Expanded
- ' Uncomment the following line to display the children
- ' of the selected node in the ListBox control
- ' If Nd.Children > 0 Then
- ' List1.Clear
- ' Set childNd = Nd.Child
- ' For i = 0 To Nd.Children - 1
- ' List1.AddItem childNd.Text
- ' Set childNd = childNd.Next
- ' Next
- ' End If
- Set Nd = Node
- If Nd.Tag = "GLOBE" Then Exit Sub
- If Nd.Tag = "Cities" Then
- Text3.Text = Nd.Text
- Set Nd = Nd.Parent
- Text2.Text = Nd.Text
- Set Nd = Nd.Parent
- Text1.Text = Nd.Text
- ElseIf Nd.Tag = "Countries" Then
- Text3.Text = ""
- Text2.Text = Nd.Text
- Set Nd = Nd.Parent
- Text1.Text = Nd.Text
- Else
- Text1.Text = Nd.Text
- Text2.Text = ""
- Text3.Text = ""
- End If
- End Sub
-