Feb 22 2022 03:47 AM
I am trying to implement a doubly linked list. I have two class modules, one for each node and one for the linked list.
Node:
Option Explicit
Private Value As Long
Private prevNode As Node
Private nextNode As Node
Linked List:
Option Explicit
Private head As Node
Public Sub Add(inputValue As Long)
Dim newNode As Node
Set newNode = New Node
newNode.Value = inputValue
Set newNode.nextNode = head
Set head = newNode
End Sub
I am then trying to test the code by making a test module which just adds some nodes:
Option Explicit
Sub Test()
Dim linkedList As New linkedList
linkedList.Add (1)
linkedList.Add (2)
linkedList.Add (3)
linkedList.Add (4)
End Sub
It is saying the that "newNode.Value = inputValue" line throws the error. Why is this happening as the Value attribute is in the Node class?
Feb 22 2022 04:03 AM
SolutionFeb 22 2022 04:08 AM
You declared the three properties if Node as Private, so they are not visible to other modules.
Either declare them as Public, or create Get/Let/Set methods for them.
Feb 22 2022 04:03 AM
Solution