Home All Groups Group Topic Archive Search About

How to implement Link List in VB 6.0?

Author
20 Mar 2006 5:27 AM
Peri
Dear All,

Can anyone help me out in implementing Link List in VB 6.0 ?

Thanks in advance

Peri

Author
20 Mar 2006 7:40 AM
Jim Carlock
"Peri" <p***@CSPL.com> wrote:
> Can anyone help me out in implementing Link List in VB 6.0 ?

You mean something like:

Private Type tStruct
  sName As String
  iID As Long
  iPrevious As Long
  iNext As Long
End Type

Private aItems() As tStruct

Public Sub main()
  Dim i As Long
  ReDim aItems(10)
  For i = 1 to 10
    With aItems(i - 1)
      .Name = CStr(i)
      .ID = i - 1
      .Previous = i - 2
      .Next = i
    End With
  Next i
End Sub

Hope this helps.

Jim Carlock
Post replies to the group.
Author
20 Mar 2006 8:33 AM
J French
On Mon, 20 Mar 2006 10:57:10 +0530, "Peri" <p***@CSPL.com> wrote:

>Dear All,
>
>Can anyone help me out in implementing Link List in VB 6.0 ?

Do you /really/ want to use a Linked List
- or is this a homework assignment

For real code Linked Lists are a PITA
Author
20 Mar 2006 2:02 PM
Robert Conley
Peri wrote:
> Dear All,
>
> Can anyone help me out in implementing Link List in VB 6.0 ?
>
> Thanks in advance
>
> Peri

Class SomeObject
     Public Data as Double
     Public PrevPtr as SomeObject
     Public NextPtr as SomeObject

     Public Sub LinkThis(NewLink as SomeObject)
            Set Me.NextPtr = NewLink
            Set NewLink.PrevPtr = Me
     End Sub
End Class

Module modMain
  Sub Main()
      Dim Temp as SomeObject
      Dim Head as SomeObject
      Set Temp = New SomeObject
      Set Head = Temp
      Temp.Data = 1.1
      Temp.LinkThis New SomeObject
      Set Temp = Temp.NextPtr
      Temp.Data = 2.2
      Temp.LinkThis New SomeObject
      Set Temp = Temp.NextPtr
      Temp.Data = 3.3

      Set Temp = Head
      Do Until Temp is Nothing
           MsgBox Temp.Data
           Set Temp = Temp.NextPtr
      Loop
  End Sub
End Module