Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function IsChild(ByVal Node As MSComctlLib.Node) As Boolean
IsChild = (Not Node.Parent Is Nothing)
End Function
Function IsSibling(ByVal Node As MSComctlLib.Node) As Boolean
IsSibling = ((Not Node.Next Is Nothing) or (Not Node.Previous Is Nothing))
End Function
Function IsParent(ByVal Node As MSComctlLib.Node) As Boolean
IsParent = (Not Node.Children = 0)
End Function
<XMLTree>
<Node Name="Node1" Parent="" Text="Test 1">
<Node Name="Node2" Parent="Node1" Text="Test 2">
<Node Name="Node4" Parent="Node2" Text="Test 4">
<Node Name="Node6" Parent="Node4" Text="Test 6">
</Node>
<Node Name="Node5" Parent="Node2" Text="Test 5">
</Node>
</Node>
<Node Name="Node3" Parent="Node1" Text="Test 3">
<Node Name="Node7" Parent="Node3" Text="Test 7">
<Node Name="Node8" Parent="Node7" Text="Test 8">
</Node>
</Node>
</Node>
</XMLTree>
Function SaveTree(Tree As MSComctlLib.TreeView) As String
Dim Text As String
Dim Node As MSComctlLib.Node
For Each Node In Tree.Nodes
If Not Node.Parent Is Nothing Then
Text = Text & Node.Text & "|" & Node.Parent.Index & vbCrLf
Else
Text = Text & Node.Text & "|" & vbCrLf
End If
Next
SaveTree = Text
End Function
Sub RestoreTree(Tree As MSComctlLib.TreeView, Text As String)
Dim tNodes() As String
Dim tNode() As String
Dim i As Integer
Tree.Nodes.Clear
tNodes = Split(Text & vbCrLf, vbCrLf)
For i = 0 To UBound(tNodes)
If InStr(1, tNodes(i), "|") Then
tNode = Split(tNodes(i), "|")
If tNode(1) <> "" Then
Tree.Nodes.Add Tree.Nodes(Val(tNode(1))), tvwChild, , tNode(0)
Else
Tree.Nodes.Add , , , tNode(0)
End If
End If
Next
End Sub
Open "file.txt" For Output As #1
Print #1, SaveTree(TreeView1)
Close
Open "file.txt" For Input As #1
RestoreTree TreeView1, Input(LOF(1), #1)
Close