To prevent further theoretical discussions, I just coded some fully working example (see below, you can use copy&paste).
You need
Form1 : Form
Component added : TreeView.dll
Tree: TreeView
Node, TempNode: Node
---
Here's the error message:
An error occured on sub recursivedescent
Line numer: 70
TempNode.Value = nodeAsParameter
Error description:
Das Object mit dem Typ System.Int32 kann nicht in den Typ Systems.Windows.Forms.TreeNode konvertiert werden.
Continue?
[Buttons Yes/No]
Translation of error:
The object with type System.Int32 cannot be converted to type Systems.Windows.Forms.TreeNode.
---
Heres the sample code:
-- 8< -- snip -
Sub Globals
'Declare the global variables here.
Dim Result
End Sub
Sub App_Start
Form1.Show
' Initialize Tree
Tree.New1("Form1", 0, 0, 200,200)
Tree.AddNewNode("Root")
Node.New1
Node.Value = Tree.GetNode(0)
Node.AddNewNode("Level 1.1")
Node.AddNewNode("Level 1.2")
Node.AddNewNode("Level 1.3")
Node.Value = Node.GetNode(0)
Node.AddNewNode("Level 2.1")
Node.AddNewNode("Level 2.2")
Node.Value = Node.Parent
Node.Value = Node.GetNode(1)
Node.AddNewNode("Level 2.3")
Node.AddNewNode("Level 2.4")
Tree.ExpandAll
' Initialize TempNode
TempNode.New1
' Prepare Result of recursive call
Result = ""
' Initialize node for recursive call
Node.Value = Tree.GetNode(0)
' No recursion: Works fine!
UseNode(Node.Value)
' Recursice Call
RecursiveDescent(Node.Value)
' Use result
Msgbox(Result,"Result")
End Sub
Sub UseNode(nodeAsParameter)
' Assign Temp Node
TempNode.Value = nodeAsParameter
' Sample use
Msgbox(TempNode.Text, "It Works")
TempNode.Text = "New name"
Msgbox(TempNode.Text, "It Still Works")
End Sub
Sub RecursiveDescent(nodeAsParameter)
' Assign Temp Node (works!)
TempNode.Value = nodeAsParameter
Msgbox(TempNode.Text, "It Works in First Line")
' Do something for each node:
Result = Result & TempNode.Text & crlf
nodeCount = TempNode.Count - 1
For i = 0 To nodeCount
' This will overwrite TempNode
TempNode.Value = TempNode.GetNode(i)
RecursiveDescent(TempNode.Value)
' Reset TempNode after recursion (does not work!!!)
' Exactly the same as in first line of sub!
TempNode.Value = nodeAsParameter
Next
End Sub
-- 8< -- snip -