int *ptrInt;
Private *ptrInt As Integer // ?????
int *ptrInt;
Private *ptrInt As Integer // ?????
Option Explicit
Public a As Double, b As Double, c As Double, d As Double
Public pNext As CPlane
Public pPrev As CPlane
Option Explicit
' Pointers to first and last plane in the list
Dim pFirst As CPlane
Dim pLast As CPlane
' The planes list
Dim PlaneList As CPlane
Private Sub Form_Load()
Dim i As Long ' silly counter
Dim tmpPlane As CPlane ' Temporary pointer to store the new plane while creating
Set PlaneList = New CPlane ' Instantiate the new CPlane object
With PlaneList ' Fill up the members, you should use Properties instead of public members
.a = i * 1.234
.b = i * 5.678
.c = i * 9.012
.d = i * 3.456
End With
Set pFirst = PlaneList ' Set the pointer to the first plane in the list
For i = 1 To 10 ' Crate 10 new elements for the list
Set tmpPlane = New CPlane ' New plane
With tmpPlane ' Fill data. The With statement is used to keep the reference to the object for every time you call it's members. You must use it to do good coding
.a = i * 1.234
.b = i * 5.678
.c = i * 9.012
.d = i * 3.456
Set .pPrev = PlaneList
End With
Set PlaneList.pNext = tmpPlane ' You know
Set PlaneList = tmpPlane
Next
Set pLast = PlaneList ' Set the pointer to the last element
Set PlaneList = pFirst
For i = 1 To 10 ' Loop the list and show the a member value
MsgBox CStr(PlaneList.a)
Set PlaneList = PlaneList.pNext
Next
Set PlaneList = pFirst
End Sub
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more