home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch08 / globe / mentries / tview.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-22  |  25.6 KB  |  699 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form GlobeForm 
  4.    Appearance      =   0  'Flat
  5.    BackColor       =   &H80000000&
  6.    Caption         =   "TreeView Demo (with non-unique items)"
  7.    ClientHeight    =   6780
  8.    ClientLeft      =   165
  9.    ClientTop       =   735
  10.    ClientWidth     =   8430
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   6780
  13.    ScaleWidth      =   8430
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.Frame Frame2 
  16.       Height          =   6525
  17.       Left            =   5280
  18.       TabIndex        =   8
  19.       Top             =   0
  20.       Width           =   3015
  21.       Begin VB.ListBox List1 
  22.          BeginProperty Font 
  23.             Name            =   "Verdana"
  24.             Size            =   9
  25.             Charset         =   0
  26.             Weight          =   400
  27.             Underline       =   0   'False
  28.             Italic          =   0   'False
  29.             Strikethrough   =   0   'False
  30.          EndProperty
  31.          Height          =   3000
  32.          Left            =   150
  33.          TabIndex        =   13
  34.          Top             =   240
  35.          Width           =   2685
  36.       End
  37.       Begin VB.CommandButton ListCities 
  38.          Caption         =   "List Cities"
  39.          BeginProperty Font 
  40.             Name            =   "Verdana"
  41.             Size            =   9.75
  42.             Charset         =   0
  43.             Weight          =   400
  44.             Underline       =   0   'False
  45.             Italic          =   0   'False
  46.             Strikethrough   =   0   'False
  47.          EndProperty
  48.          Height          =   480
  49.          Left            =   480
  50.          TabIndex        =   12
  51.          Top             =   5895
  52.          Width           =   2145
  53.       End
  54.       Begin VB.CommandButton ListContinents 
  55.          Caption         =   "List Continents"
  56.          BeginProperty Font 
  57.             Name            =   "Verdana"
  58.             Size            =   9.75
  59.             Charset         =   0
  60.             Weight          =   400
  61.             Underline       =   0   'False
  62.             Italic          =   0   'False
  63.             Strikethrough   =   0   'False
  64.          EndProperty
  65.          Height          =   480
  66.          Left            =   480
  67.          TabIndex        =   11
  68.          Top             =   4440
  69.          Width           =   2145
  70.       End
  71.       Begin VB.CommandButton ListCountries 
  72.          Caption         =   "List Countries"
  73.          BeginProperty Font 
  74.             Name            =   "Verdana"
  75.             Size            =   9.75
  76.             Charset         =   0
  77.             Weight          =   400
  78.             Underline       =   0   'False
  79.             Italic          =   0   'False
  80.             Strikethrough   =   0   'False
  81.          EndProperty
  82.          Height          =   480
  83.          Left            =   495
  84.          TabIndex        =   10
  85.          Top             =   5175
  86.          Width           =   2145
  87.       End
  88.       Begin VB.CommandButton FindCity 
  89.          Caption         =   "Find KEY"
  90.          BeginProperty Font 
  91.             Name            =   "Verdana"
  92.             Size            =   9.75
  93.             Charset         =   0
  94.             Weight          =   400
  95.             Underline       =   0   'False
  96.             Italic          =   0   'False
  97.             Strikethrough   =   0   'False
  98.          EndProperty
  99.          Height          =   480
  100.          Left            =   480
  101.          TabIndex        =   9
  102.          Top             =   3705
  103.          Width           =   2145
  104.       End
  105.    End
  106.    Begin VB.CommandButton ExpandNodeBttn 
  107.       Caption         =   "Expand Current Node"
  108.       BeginProperty Font 
  109.          Name            =   "Verdana"
  110.          Size            =   9.75
  111.          Charset         =   0
  112.          Weight          =   400
  113.          Underline       =   0   'False
  114.          Italic          =   0   'False
  115.          Strikethrough   =   0   'False
  116.       EndProperty
  117.       Height          =   465
  118.       Left            =   2625
  119.       TabIndex        =   7
  120.       Top             =   3435
  121.       Width           =   2400
  122.    End
  123.    Begin VB.CommandButton DeleteNodeBttn 
  124.       Caption         =   "Delete Current Node"
  125.       BeginProperty Font 
  126.          Name            =   "Verdana"
  127.          Size            =   9.75
  128.          Charset         =   0
  129.          Weight          =   400
  130.          Underline       =   0   'False
  131.          Italic          =   0   'False
  132.          Strikethrough   =   0   'False
  133.       EndProperty
  134.       Height          =   465
  135.       Left            =   180
  136.       TabIndex        =   6
  137.       Top             =   3435
  138.       Width           =   2400
  139.    End
  140.    Begin VB.CommandButton AddEntry 
  141.       Caption         =   "Add this Node"
  142.       BeginProperty Font 
  143.          Name            =   "Verdana"
  144.          Size            =   9.75
  145.          Charset         =   0
  146.          Weight          =   400
  147.          Underline       =   0   'False
  148.          Italic          =   0   'False
  149.          Strikethrough   =   0   'False
  150.       EndProperty
  151.       Height          =   465
  152.       Left            =   3210
  153.       TabIndex        =   4
  154.       Top             =   5835
  155.       Width           =   1575
  156.    End
  157.    Begin VB.TextBox Text3 
  158.       BeginProperty Font 
  159.          Name            =   "Verdana"
  160.          Size            =   9
  161.          Charset         =   0
  162.          Weight          =   400
  163.          Underline       =   0   'False
  164.          Italic          =   0   'False
  165.          Strikethrough   =   0   'False
  166.       EndProperty
  167.       Height          =   330
  168.       Left            =   2535
  169.       TabIndex        =   3
  170.       Top             =   5310
  171.       Width           =   2220
  172.    End
  173.    Begin VB.TextBox Text2 
  174.       BeginProperty Font 
  175.          Name            =   "Verdana"
  176.          Size            =   9
  177.          Charset         =   0
  178.          Weight          =   400
  179.          Underline       =   0   'False
  180.          Italic          =   0   'False
  181.          Strikethrough   =   0   'False
  182.       EndProperty
  183.       Height          =   330
  184.       Left            =   1590
  185.       TabIndex        =   2
  186.       Top             =   4890
  187.       Width           =   2220
  188.    End
  189.    Begin VB.TextBox Text1 
  190.       BeginProperty Font 
  191.          Name            =   "Verdana"
  192.          Size            =   9
  193.          Charset         =   0
  194.          Weight          =   400
  195.          Underline       =   0   'False
  196.          Italic          =   0   'False
  197.          Strikethrough   =   0   'False
  198.       EndProperty
  199.       Height          =   330
  200.       Left            =   345
  201.       TabIndex        =   1
  202.       Top             =   4425
  203.       Width           =   2220
  204.    End
  205.    Begin ComctlLib.TreeView TreeView1 
  206.       Height          =   3105
  207.       Left            =   165
  208.       TabIndex        =   0
  209.       Top             =   165
  210.       Width           =   4890
  211.       _ExtentX        =   8625
  212.       _ExtentY        =   5477
  213.       _Version        =   393217
  214.       HideSelection   =   0   'False
  215.       LabelEdit       =   1
  216.       Sorted          =   -1  'True
  217.       Style           =   6
  218.       HotTracking     =   -1  'True
  219.       Appearance      =   1
  220.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  221.          Name            =   "Verdana"
  222.          Size            =   9
  223.          Charset         =   0
  224.          Weight          =   400
  225.          Underline       =   0   'False
  226.          Italic          =   0   'False
  227.          Strikethrough   =   0   'False
  228.       EndProperty
  229.       _Nodes          =   "TView.frx":0000
  230.    End
  231.    Begin VB.Frame Frame1 
  232.       Height          =   2430
  233.       Left            =   150
  234.       TabIndex        =   5
  235.       Top             =   4065
  236.       Width           =   4905
  237.       Begin VB.Line Line1 
  238.          X1              =   375
  239.          X2              =   375
  240.          Y1              =   690
  241.          Y2              =   1395
  242.       End
  243.       Begin VB.Line Line2 
  244.          X1              =   1455
  245.          X2              =   375
  246.          Y1              =   975
  247.          Y2              =   975
  248.       End
  249.       Begin VB.Line Line4 
  250.          X1              =   2400
  251.          X2              =   360
  252.          Y1              =   1395
  253.          Y2              =   1395
  254.       End
  255.    End
  256.    Begin ComctlLib.ImageList ImageList1 
  257.       Left            =   15
  258.       Top             =   3675
  259.       _ExtentX        =   1005
  260.       _ExtentY        =   1005
  261.       BackColor       =   -2147483643
  262.       MaskColor       =   12632256
  263.       _Version        =   393216
  264.    End
  265.    Begin VB.Menu FileMenu 
  266.       Caption         =   "File"
  267.       Begin VB.Menu FileLoad 
  268.          Caption         =   "Load Control"
  269.       End
  270.       Begin VB.Menu FileSave 
  271.          Caption         =   "Save Control"
  272.       End
  273.       Begin VB.Menu sep 
  274.          Caption         =   "-"
  275.       End
  276.       Begin VB.Menu FileExit 
  277.          Caption         =   "Exit"
  278.       End
  279.    End
  280. Attribute VB_Name = "GlobeForm"
  281. Attribute VB_GlobalNameSpace = False
  282. Attribute VB_Creatable = False
  283. Attribute VB_PredeclaredId = True
  284. Attribute VB_Exposed = False
  285. '  ******************************
  286. '  ******************************
  287. '  ** MASTERING VB6            **
  288. '  ** by Evangelos Petroutos   **
  289. '  ** SYBEX, 1998              **
  290. '  ******************************
  291. '  ******************************
  292. Option Explicit
  293. Private Sub FileLoad_Click()
  294. Dim FNum As Integer
  295. Dim Nd As Node
  296. Dim level1 As String, level2 As String
  297. Dim key As String, thisItem As String
  298. Dim nodeText As String
  299. TreeView1.Nodes.Clear
  300. ' set up the ListImage object
  301. Dim Images As ListImage
  302.     Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\cont.bmp"))
  303.     Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\country.bmp"))
  304.     Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\city.bmp"))
  305.     TreeView1.ImageList = ImageList1
  306.     FNum = FreeFile()
  307.     Set Nd = TreeView1.Nodes.Add(, , "GLOBE", "Globe", 1)
  308.     Nd.Tag = "GLOBE"
  309.     Nd.Sorted = True
  310.     Open App.Path & "\MGlobe.txt" For Input As #FNum
  311.     While Not EOF(FNum)
  312.         Input #FNum, nodeText
  313.         thisItem = UCase(Trim(nodeText))
  314.         If Left(nodeText, 3) = "   " Then
  315.             key = level2 & "-" & thisItem
  316.             Set Nd = TreeView1.Nodes.Add(level2, tvwChild, key, Trim(nodeText), 3)
  317.             Nd.Tag = "Cities"
  318.         ElseIf Left(nodeText, 2) = "  " Then
  319.             level2 = level1 & "-" & thisItem
  320.             key = level2
  321.             Set Nd = TreeView1.Nodes.Add(level1, tvwChild, key, Trim(nodeText), 2)
  322.             Nd.Tag = "Countries"
  323.             Nd.Sorted = True
  324.         ElseIf Left(nodeText, 1) = " " Then
  325.             level1 = thisItem
  326.             key = level1
  327.             Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, key, Trim(nodeText), 1)
  328.             Nd.Tag = "Continents"
  329.             Nd.Sorted = True
  330.         End If
  331.     Wend
  332.     Close #FNum
  333. End Sub
  334. Private Sub FileSave_Click()
  335. Dim Nd As Node, countryNd As Node, continentNd As Node, cityNd As Node
  336. Dim continent As Integer, continents As Integer
  337. Dim country As Integer, countries As Integer
  338. Dim city As Integer, cities As Integer
  339. Dim FNum As Integer
  340.     FNum = FreeFile()
  341.     Open App.Path & "\MGlobe.txt" For Output As #FNum
  342.     Set Nd = TreeView1.Nodes.Item("GLOBE")
  343. Debug.Print Nd.Text
  344.     Write #FNum, Nd.Text
  345.     continents = Nd.Children
  346.     Set continentNd = Nd.Child
  347.     For continent = 1 To continents
  348. Debug.Print continentNd.Text
  349.         Write #FNum, " " & continentNd.Text
  350.         countries = continentNd.Children
  351.         Set countryNd = continentNd.Child
  352.         For country = 1 To countries
  353. Debug.Print "   " & countryNd.Text
  354.             Write #FNum, "  " & countryNd.Text
  355.             cities = countryNd.Children
  356.             Set cityNd = countryNd.Child
  357.             For city = 1 To cities
  358. Debug.Print "      " & cityNd.Text
  359.                 Write #FNum, "   " & cityNd.Text
  360.                 Set cityNd = cityNd.Next
  361.             Next
  362.             Set countryNd = countryNd.Next
  363.         Next
  364.         Set continentNd = continentNd.Next
  365.     Next
  366.     Close #FNum
  367. End Sub
  368. Private Sub AddEntry_Click()
  369. Dim newNode As Node
  370. Dim NodeContinent As Node, NodeCountry As Node, NodeCity As Node
  371. On Error Resume Next
  372.     If Trim(Text1.Text) = "" Then
  373.         MsgBox "Please supply a valid key in the form Continent-Country-City"
  374.         Exit Sub
  375.     End If
  376.     Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text))
  377.     If Error Then
  378.         Set newNode = TreeView1.Nodes.Add("GLOBE", tvwChild, UCase$(Text1.Text), Text1.Text, 2)
  379.         newNode.Tag = "Continents"
  380.     End If
  381.     If Trim(Text2.Text) = "" Then Exit Sub
  382.     Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text & "-" & Text2.Text))
  383.     If Error Then
  384.         Set newNode = TreeView1.Nodes.Add(UCase$(Text1.Text), tvwChild, UCase$(Text1.Text & "-" & Text2.Text), Text2.Text, 3)
  385.         newNode.Tag = "Countries"
  386.     End If
  387.     If Trim(Text3.Text) = "" Then Exit Sub
  388.     Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text & "-" & Text2.Text & "-" & Text3.Text))
  389.     If Error Then
  390.         Set newNode = TreeView1.Nodes.Add(UCase$(Text1.Text & "-" & Text2.Text), tvwChild, UCase$(Text1.Text & "-" & Text2.Text & "-" & Text3.Text), Text3.Text)
  391.         newNode.Tag = "Cities"
  392.     End If
  393.     TreeView1.SelectedItem = newNode
  394. End Sub
  395. Private Sub DeleteNodeBttn_Click()
  396.     TreeView1.Nodes.Remove (TreeView1.SelectedItem.Index)
  397.     Text1.Text = ""
  398.     Text2.Text = ""
  399.     Text3.Text = ""
  400. End Sub
  401. Private Sub ExpandNodeBttn_Click()
  402.     TreeView1.SelectedItem.Expanded = True
  403. End Sub
  404. Private Sub FindCity_Click()
  405. Dim Nd As Node, ParentNd As Node
  406. Dim NodeName As String, NodeKey As String
  407. Text1.Text = ""
  408. Text2.Text = ""
  409. Text3.Text = ""
  410. On Error GoTo NoCity
  411.     NodeName = InputBox("Enter name of node")
  412.     NodeKey = UCase$(Trim(NodeName))
  413.     Set Nd = TreeView1.Nodes.Item(NodeKey)
  414.     TreeView1.SelectedItem = Nd
  415.     Text1.Text = Nd.Text
  416.     Set ParentNd = Nd.Parent
  417.     If Not ParentNd Is Nothing Then
  418.         If ParentNd.key = "GLOBE" Then
  419.             Exit Sub
  420.         Else
  421.             NodeKey = UCase$(ParentNd.key)
  422.             TreeView1.Nodes(NodeKey).Expanded = True
  423.             Text2.Text = Text1.Text
  424.             Text1.Text = ParentNd.Text
  425.         End If
  426.     End If
  427.     Set ParentNd = ParentNd.Parent
  428.     If Not ParentNd Is Nothing Then
  429.         If ParentNd.key = "GLOBE" Then
  430.             Exit Sub
  431.         Else
  432.             NodeKey = UCase$(ParentNd.key)
  433.             TreeView1.Nodes(NodeKey).Expanded = True
  434.             Text3.Text = Text2.Text
  435.             Text2.Text = Text1.Text
  436.             Text1.Text = ParentNd.Text
  437.         End If
  438.     End If
  439.     Set ParentNd = ParentNd.Parent
  440.     If Not ParentNd Is Nothing Then
  441.         If Not ParentNd.key = "GLOBE" Then
  442.             NodeKey = UCase$(ParentNd.key)
  443.             TreeView1.Nodes(NodeKey).Expanded = True
  444.         End If
  445.     End If
  446.     Exit Sub
  447. NoCity:
  448.     If Err.Number = 35601 Then
  449.         MsgBox "The city you requested does not exist"
  450.     Else
  451.         MsgBox Err.Description
  452.     End If
  453. End Sub
  454. Private Sub Form_Load()
  455. Dim Images As ListImage
  456. Dim Nd As Node
  457. ' set up the ListImage object
  458. Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\cont.bmp"))
  459. Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\country.bmp"))
  460. Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\city.bmp"))
  461. TreeView1.ImageList = ImageList1
  462. ' now set up Treeview control
  463. Set Nd = TreeView1.Nodes.Add(, , "GLOBE", "Globe", 1)
  464. Nd.Tag = "GLOBE"
  465. Nd.Sorted = True
  466. Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "EUROPE", "EUROPE", 2)
  467. Nd.Tag = "Continents"
  468. Nd.Sorted = True    ' this statement sorts all countries under EUROPE
  469. Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "ASIA", "ASIA", 2)
  470. Nd.Tag = "Continents"
  471. Nd.Sorted = True    ' this statement sorts all countries under ASIA
  472. Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "AFRICA", "AFRICA", 2)
  473. Nd.Tag = "Continents"
  474. Nd.Sorted = True    ' ' this statement sorts all countries under AFRICA
  475. Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "AMERICA", "AMERICA", 2)
  476. Nd.Tag = "Continents"
  477. Nd.Sorted = True    ' this statement sorts all countries under AMERICA
  478. Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "OCEANIA", "OCEANIA", 2)
  479. Nd.Tag = "Continents"
  480. Nd.Sorted = True
  481. Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "EUROPE-GERMANY", "Germany", 3)
  482. Nd.Tag = "Countries"
  483. Nd.Sorted = True    ' this statement sorts all german cities
  484. Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-BERLIN", "Berlin")
  485. Nd.Tag = "Cities"
  486. Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-MUNICH", "Munich")
  487. Nd.Tag = "Cities"
  488. Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-BAYREUTH", "Bayreuth")
  489. Nd.Tag = "Cities"
  490. Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-FRANFURT", "Frankfurt")
  491. Nd.Tag = "Cities"
  492. Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "EUROPE-FRANCE", "France", 3)
  493. Nd.Tag = "Countries"
  494. Nd.Sorted = True    ' this statement sorts all french cities
  495. Set Nd = TreeView1.Nodes.Add("EUROPE-FRANCE", tvwChild, "EUROPE-FRANCE-PARIS", "Paris")
  496. Nd.Tag = "Cities"
  497. Set Nd = TreeView1.Nodes.Add("EUROPE-FRANCE", tvwChild, "EUROPE-FRANCE-NICE", "Nice")
  498. Nd.Tag = "Cities"
  499. Set Nd = TreeView1.Nodes.Add("EUROPE-FRANCE", tvwChild, "EUROPE-FRANCE-LYON", "Lyon")
  500. Nd.Tag = "Cities"
  501. Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "EUROPE-ITALY", "Italy", 3)
  502. Nd.Tag = "Countries"
  503. Nd.Sorted = True    ' this statement sorts all italian cities
  504. Set Nd = TreeView1.Nodes.Add("EUROPE-ITALY", tvwChild, "EUROPE-ITALY-ROME", "Rome")
  505. Nd.Tag = "Cities"
  506. Set Nd = TreeView1.Nodes.Add("EUROPE-ITALY", tvwChild, "EUROPE-ITALY-VENICE", "Venice")
  507. Nd.Tag = "Cities"
  508. Set Nd = TreeView1.Nodes.Add("EUROPE-ITALY", tvwChild, "EUROPE-ITALY-NAPOLI", "Napoli")
  509. Nd.Tag = "Cities"
  510. Set Nd = TreeView1.Nodes.Add("ASIA", tvwChild, "ASIA-CHINA", "China", 3)
  511. Nd.Tag = "Countries"
  512. Nd.Sorted = True
  513. Set Nd = TreeView1.Nodes.Add("ASIA-CHINA", tvwChild, "ASIA-CHINA-BEJING", "Bejing")
  514. Nd.Tag = "Cities"
  515. Set Nd = TreeView1.Nodes.Add("ASIA", tvwChild, "ASIA-JAPAN", "Japan", 3)
  516. Nd.Tag = "Countries"
  517. Nd.Sorted = True
  518. Set Nd = TreeView1.Nodes.Add("ASIA-JAPAN", tvwChild, "ASIA-JAPAN-TOKYO", "Tokyo")
  519. Nd.Tag = "Cities"
  520. Set Nd = TreeView1.Nodes.Add("ASIA-JAPAN", tvwChild, "ASIA-JAPAN-OSAKA", "Osaka")
  521. Nd.Tag = "Cities"
  522. Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-EGYPT", "Egypt", 3)
  523. Nd.Tag = "Countries"
  524. Nd.Sorted = True
  525. Set Nd = TreeView1.Nodes.Add("AFRICA-EGYPT", tvwChild, "AFRICA-EGYPT-CAIRO", "Cairo")
  526. Nd.Tag = "Cities"
  527. Set Nd = TreeView1.Nodes.Add("AFRICA-EGYPT", tvwChild, "AFRICA-EGYPT-ALEXANDRIA", "Alexandria")
  528. Nd.Tag = "Cities"
  529. Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-LIBYA", "Libya", 3)
  530. Nd.Tag = "Countries"
  531. Nd.Sorted = True
  532. Set Nd = TreeView1.Nodes.Add("AFRICA-LIBYA", tvwChild, "AFRICA-LIBYA-TRIPOLI", "Tripoli")
  533. Nd.Tag = "Cities"
  534. Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-SOUTH AFRICA", "South Africa", 3)
  535. Nd.Tag = "Countries"
  536. Nd.Sorted = True
  537. Set Nd = TreeView1.Nodes.Add("AFRICA-SOUTH AFRICA", tvwChild, "AFRICA-SOUTH AFRICA-JOHANNESBURG", "Johannesburg")
  538. Nd.Tag = "Cities"
  539. Set Nd = TreeView1.Nodes.Add("AFRICA-SOUTH AFRICA", tvwChild, "AFRICA-SOUTH AFRICA-PRETORIA", "Pretoria")
  540. Nd.Tag = "Cities"
  541. Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-ZIMBABWE", "Zimbabwe", 3)
  542. Nd.Tag = "Countries"
  543. Nd.Sorted = True
  544. Set Nd = TreeView1.Nodes.Add("AFRICA-ZIMBABWE", tvwChild, "AFRICA-ZIMBABWE-HARARE", "Harare")
  545. Nd.Tag = "Cities"
  546. Set Nd = TreeView1.Nodes.Add("OCEANIA", tvwChild, "OCEANIA-AUSTRALIA", "Australia", 3)
  547. Nd.Tag = "Countries"
  548. Nd.Sorted = True
  549. Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-SINDEY", "Sidney")
  550. Nd.Tag = "Cities"
  551. Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-MELBOURNE", "Melbourne")
  552. Nd.Tag = "Cities"
  553. Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-ADELAIADE", "Adelaida")
  554. Nd.Tag = "Cities"
  555. Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-BRISBANE", "Brisbane")
  556. Nd.Tag = "Cities"
  557. Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-CANBERRA", "Canberra")
  558. Nd.Tag = "Cities"
  559. Set Nd = TreeView1.Nodes.Add("OCEANIA", tvwChild, "OCEANIA-NEW ZEALAND", "New Zealand", 3)
  560. Nd.Tag = "Countries"
  561. Nd.Sorted = True
  562. Set Nd = TreeView1.Nodes.Add("OCEANIA-NEW ZEALAND", tvwChild, "OCEANIA-NEW ZEALAND-WANAKA", "Wanaka")
  563. Nd.Tag = "Cities"
  564. Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-USA", "USA", 3)
  565. Nd.Tag = "Countries"
  566. Nd.Sorted = True
  567. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-NEW YORK", "New York")
  568. Nd.Tag = "Cities"
  569. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-LAS VEGAS", "Las Vegas")
  570. Nd.Tag = "Cities"
  571. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-CHICAGO", "Chicago")
  572. Nd.Tag = "Cities"
  573. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-WASHINGTON", "Washington")
  574. Nd.Tag = "Cities"
  575. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-DURHAM", "Durham")
  576. Nd.Tag = "Cities"
  577. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-VENICE", "Venice")
  578. Nd.Tag = "Cities"
  579. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-Alexandria", "Alexandria")
  580. Nd.Tag = "Cities"
  581. Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-SAN FRANCISCO", "San Francisco")
  582. Nd.Tag = "Cities"
  583. Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-CANADA", "Canada", 3)
  584. Nd.Tag = "Countries"
  585. Nd.Sorted = True
  586. Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-TORONTO", "Toronto")
  587. Nd.Tag = "Cities"
  588. Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-VANCOUVER", "Vancouver")
  589. Nd.Tag = "Cities"
  590. Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-MONTREAL", "Montreal")
  591. Nd.Tag = "Cities"
  592. Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-HALIFAX", "Halifax")
  593. Nd.Tag = "Cities"
  594. Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-CALGARY", "Calgary")
  595. Nd.Tag = "Cities"
  596. Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-MEXICO", "Mexico", 3)
  597. Nd.Tag = "Countries"
  598. Nd.Sorted = True
  599. Set Nd = TreeView1.Nodes.Add("AMERICA-MEXICO", tvwChild, "AMERICA-MEXICO-MEXICO CITY", "Mexico City")
  600. Nd.Tag = "Cities"
  601. Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-ARGENTINA", "Argentina", 3)
  602. Nd.Tag = "Countries"
  603. Nd.Sorted = True
  604. Set Nd = TreeView1.Nodes.Add("AMERICA-ARGENTINA", tvwChild, "AMERICA-ARGENTINA-BUENOS AIRES", "Buenos Aires")
  605. Nd.Tag = "Cities"
  606. End Sub
  607. Private Sub ListCities_Click()
  608. Dim Nd As Node, countryNd As Node, continentNd As Node, cityNd As Node
  609. Dim continent As Integer, continents As Integer
  610. Dim country As Integer, countries As Integer
  611. Dim city As Integer, cities As Integer
  612.     List1.Clear
  613.     Set Nd = TreeView1.Nodes.Item("GLOBE")
  614.     continents = Nd.Children
  615.     Set continentNd = Nd.Child
  616.     For continent = 1 To continents
  617.         countries = continentNd.Children
  618.         Set countryNd = continentNd.Child
  619.         For country = 1 To countries
  620.             cities = countryNd.Children
  621.             Set cityNd = countryNd.Child
  622.             For city = 1 To cities
  623.                 List1.AddItem cityNd.Text
  624.                 Set cityNd = cityNd.Next
  625.             Next
  626.             Set countryNd = countryNd.Next
  627.         Next
  628.         Set continentNd = continentNd.Next
  629.     Next
  630. End Sub
  631. Private Sub ListContinents_Click()
  632. Dim Nd As Node, childNd As Node
  633. Dim continent As Integer, continents As Integer
  634.     List1.Clear
  635.     Set Nd = TreeView1.Nodes.Item("GLOBE")
  636.     continents = Nd.Children
  637.     Set childNd = Nd.Child
  638.     For continent = 1 To continents
  639.         List1.AddItem childNd.Text
  640.         Set childNd = childNd.Next
  641.     Next
  642. End Sub
  643. Private Sub ListCountries_Click()
  644. Dim Nd As Node, countryNd As Node, continentNd As Node
  645. Dim continent As Integer, continents As Integer
  646. Dim country As Integer, countries As Integer
  647.     List1.Clear
  648.     Set Nd = TreeView1.Nodes.Item("GLOBE")
  649.     continents = Nd.Children
  650.     Set continentNd = Nd.Child
  651.     For continent = 1 To continents
  652.         countries = continentNd.Children
  653.         Set countryNd = continentNd.Child
  654.         For country = 1 To countries
  655.             List1.AddItem countryNd.Text
  656.             Set countryNd = countryNd.Next
  657.         Next
  658.         Set continentNd = continentNd.Next
  659.     Next
  660. End Sub
  661. Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
  662. Dim Nd As Node, childNd As Node
  663. Dim i As Integer
  664.     Text1.Text = ""
  665.     Text2.Text = ""
  666.     Text3.Text = ""
  667.     Set Nd = Node
  668.     Me.Caption = Nd.FullPath
  669.     Nd.Expanded = Not Nd.Expanded
  670. ' Uncomment the following lines to display the
  671. ' current node's children in the ListBox control
  672. '    If Nd.Children > 0 Then
  673. '        List1.Clear
  674. '        Set childNd = Nd.Child
  675. '        For i = 0 To Nd.Children - 1
  676. '            List1.AddItem childNd.Text
  677. '            Set childNd = childNd.Next
  678. '        Next
  679. '     End If
  680.      Set Nd = Node
  681.      If Nd.Tag = "GLOBE" Then Exit Sub
  682.      If Nd.Tag = "Cities" Then
  683.         Text3.Text = Nd.Text
  684.         Set Nd = Nd.Parent
  685.         Text2.Text = Nd.Text
  686.         Set Nd = Nd.Parent
  687.         Text1.Text = Nd.Text
  688.      ElseIf Nd.Tag = "Countries" Then
  689.         Text3.Text = ""
  690.         Text2.Text = Nd.Text
  691.         Set Nd = Nd.Parent
  692.         Text1.Text = Nd.Text
  693.      Else
  694.          Text1.Text = Nd.Text
  695.          Text2.Text = ""
  696.          Text3.Text = ""
  697.      End If
  698. End Sub
  699.