Private Const KILL_POINTER = 999
Private Const SENTINEL = 0
Private Type LinkedList
ListData As String
ListPointer As Long
End Type
Private MyLinkedList() As LinkedList
Private Sub Form_Load()
Dim ptr As Long
'Add Sentinel
ReDim MyLinkedList(0)
'Add Element 1
AddItem SENTINEL, "Love", 2
'Add Element 2
AddItem 1, "Linked", 3
'Add Element 3
AddItem 2, "Lists", KILL_POINTER
'Add Element 4
AddItem SENTINEL, "I", 1
ptr = SENTINEL
'The loop will end when the kill pointer is found
Do While ptr <> KILL_POINTER
If ptr <> SENTINEL Then MsgBox MyLinkedList(ptr).ListData
ptr = MyLinkedList(ptr).ListPointer
Loop
End Sub
Private Sub AddItem(Parent As Long, Data As String, ptr As Long)
'Create a new Element
ReDim Preserve MyLinkedList(UBound(MyLinkedList) + 1)
'Write data to the element
MyLinkedList(UBound(MyLinkedList)).ListData = Data
MyLinkedList(UBound(MyLinkedList)).ListPointer = ptr
'Change Parent pointer to point to this new element
MyLinkedList(Parent).ListPointer = UBound(MyLinkedList)
End Sub