|
-
September 24th, 2005, 03:00 PM
#1
Debugging Help Please
I've created a doubley linked list via classes. That whole list works fine. I can traverse it no problem. However, values I store in each node aren't saved/carried over. The following lines are where the problem is noticed:
1) list.lastNode = New clsNode(x, y)
2) list.firstNode = list.lastNode
and
1) currentNode = New clsNode(x, y, , list.firstNode)
2) list.firstNode.prevNode = currentNode
lets say y = 100 in line (1), when I execute the line (2), Y is still set to the default 0 for node. Why aren't the values kept? I've verified that the x and y values carry over to the clsNode::New sub. I know its probably something small i'm overlooking. I've tried using structures instead, but same problem occurs. Following is my stripped down code. Thanx.
Code:
Public Class clsNode
Public point As PointF
Public prevNode As clsNode
Public nextNode As clsNode
Public Sub New(ByVal x As Single, ByVal y As Single, Optional ByVal prev As clsNode = Nothing, Optional ByVal nxt As clsNode = Nothing)
Dim point As New PointF(x, y)
Me.prevNode = prev
Me.nextNode = nxt
End Sub
End Class
Public Class clsList
Public firstNode As clsNode = Nothing '//First node in entire list
Public lastNode As clsNode = Nothing '//Last node in entire list
End Class
Public Class frmCG
Public currentNode As clsNode '//Used to iterate through the list
Private testList As New clsList
Private Sub addValue(ByRef list As clsList, ByVal value As Single)
Dim x As Single = 0
Dim y As Single = 150 - value
If (list.firstNode Is Nothing) Then '//If list hasn't been started yet
list.lastNode = New clsNode(x, y)
list.firstNode = list.lastNode
Else '//Else push_front
currentNode = New clsNode(x, y, , list.firstNode)
list.firstNode.prevNode = currentNode
list.firstNode = currentNode
Do
currentNode = currentNode.nextNode
currentNode.point.X += 2
Loop Until (currentNode.nextNode Is Nothing)
End If
End Sub
End Class
Note testList is passed to sub AddValue from some other arbitruary sub.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|