B
brad langhorst
I'm going over a result set and adding results as levels on
the tree control.
when stepping through the code i see execution switch to
the calling subroutine as soon as the parentnode.nodes.add
is called. Seems like i'm trampling some variable (btw:
why doesn't that raise an error?)
I'm a fairly experienced programmer but i'm new to vb.net
so maybe this is something trivial...
here's my code
While rdrCCOA.Read
'results must be ordered by coalinekey and name to work
levelname = CStr(rdrCCOA.GetValue(0))
levelpart = CStr(rdrCCOA.GetValue(1))
level = CInt(rdrCCOA.GetValue(2))
coalinekey = CInt(rdrCCOA.GetValue(3))
acctno = CStr(rdrCCOA.GetValue(4))
'keep adding until coalinekey changes
Select Case level
Case 1 'create new root node if this one is not
already there
parentNode = findNode(acctTree, levelname)
If (IsNothing(parentNode)) Then 'not already
present add it
parentNode = New TreeNode(levelname)
acctTree.Nodes.Add(parentNode)
End If
Case Else 'add below that node
If IsNothing(parentNode) Then Throw New
Exception("deep node found with no parent")
parentNode = findNode(acctTree, levelname)
If IsNothing(parentNode) Then 'not already
present, add it
newNode = New TreeNode(levelname)
parentNode.Nodes.Add(newNode)
parentNode = newNode
End If
End Select
End While
the tree control.
when stepping through the code i see execution switch to
the calling subroutine as soon as the parentnode.nodes.add
is called. Seems like i'm trampling some variable (btw:
why doesn't that raise an error?)
I'm a fairly experienced programmer but i'm new to vb.net
so maybe this is something trivial...
here's my code
While rdrCCOA.Read
'results must be ordered by coalinekey and name to work
levelname = CStr(rdrCCOA.GetValue(0))
levelpart = CStr(rdrCCOA.GetValue(1))
level = CInt(rdrCCOA.GetValue(2))
coalinekey = CInt(rdrCCOA.GetValue(3))
acctno = CStr(rdrCCOA.GetValue(4))
'keep adding until coalinekey changes
Select Case level
Case 1 'create new root node if this one is not
already there
parentNode = findNode(acctTree, levelname)
If (IsNothing(parentNode)) Then 'not already
present add it
parentNode = New TreeNode(levelname)
acctTree.Nodes.Add(parentNode)
End If
Case Else 'add below that node
If IsNothing(parentNode) Then Throw New
Exception("deep node found with no parent")
parentNode = findNode(acctTree, levelname)
If IsNothing(parentNode) Then 'not already
present, add it
newNode = New TreeNode(levelname)
parentNode.Nodes.Add(newNode)
parentNode = newNode
End If
End Select
End While