The loop chain list and related operations (VB implementation) first build a project, then add a class and named (Node, CLS), add the following code in Node.cls .Option Explicitpublic X as longpublic count as longpublic nextnode as node in Form1. The following code is added to the FRM. Option Explicit Dim head As node Dim pointer As node Dim newnode As node Dim n As nodeDim counts As LongDim temp As nodePrivate Sub createlist_Click () Dim n As node Dim i As Long counts = 0 Set head = New node 'optional. Normally use New when declaring so you can implicate an object. If New is used with SET, a new instance of this class will be created. If Objectvar contains an object reference, release the reference head.x = 8 set head.nextNode = 8 set head.nextNode = Nothing count = counts 1 head.count = counts set pointer = head for i = 1 to 15 set newnode = New node newnode.x = i counts = counts 1 newnode.count = counts Set newnode.nextnode = Nothing Set pointer.nextnode = newnode Set pointer = newnode Next i Set pointer.nextnode = head Set pointer = head Do Print pointer. X set Pointer = POINTER.NEXTNODE IF OBJPTR (POINTER) = Objptr (Head) THEN 'OBJPTR Returns the address of the object EXIT SUB' STRPTR Returns the restented string Data address address End if 'Varptr Returns the address of the variable DOEvents' Get a variable address is a function.
Loop While NOT POINTER IS NOTHINGEND SUBPRIVATE SUB DELETE_CLICK () DIM A AS Long Dim B As long a = clng ("Enter a data to be deleted", "InputBox") B = CLNG ("InputBox" Position "," position ")) set pointer = head if b = 1 Then do set pointer = Pointer.nextNode if Objptr (Pointer.NextNode) = objptr (head) THEN SET POINTER.NEXTNODE = head.nextNode set head = nothing Set head = pointer.nextnode Exit Do End If DoEvents Loop While Not pointer Is Nothing counts = 1 Set pointer = head pointer.count = counts Do counts = counts 1 Set pointer = pointer.nextnode pointer.count = counts If ObjPtr (pointer .nextnode) = ObjPtr (head) Then Exit Do End If DoEvents Loop While Not pointer Is NothingElse While pointer.count <> b Set n = New node Set n = pointer Set pointer = pointer.nextnode DoEvents Wend Set n.nextnode = pointer . nextnode Set pointer = Nothing Set pointer = n End If counts = 0 Set pointer = head counts = counts 1 pointer.count = counts Do counts = counts 1 Set pointer = pointer.nextnode pointer.count = counts If ObjPtr (pointer. NextNode) = Objptr (Head) THEN EXIT DO END IFEVENTS LOOP While Not Pointer IS NOTHINGEND SUBPRIVATE SUB INSERT_CLICK () DIM A AS Long Dim B as long a = clng ("InputBox (" Enter a data to be inserted "," Enter data ")) B = CLNG (INPUTBOX (" Enter the location of this data "," location "
)) SET POINTER = Head if b = 1 Then Head.x = a else While Pointer.count <> b Set Pointer = Pointer.nextNode Doevents WEND POINTER.X = a End IFEND SUBPRIVATE SUB INSERT2_CLICK () DIM A AS Long Dim B As long a = clng ("Enter the input to be deleted", "Input Data")) B = CLNG (InputBox ("Enter the location of this data", "location")) SET POINTER = HEAD IF B = 1 Then Set n = New node nx = a Set n.nextnode = Nothing Do Set pointer = pointer.nextnode If ObjPtr (pointer.nextnode) = ObjPtr (head) Then Set pointer.nextnode = n Set n.nextnode = head Set head = n Exit Do End If Loop While Not pointer Is Nothing Set pointer = head counts = 1 pointer.count = 1 Do counts = counts 1 Set pointer = pointer.nextnode pointer.count = counts If ObjPtr (pointer.nextnode) = ObjPtr ( Head) THEN EXIT DO End if loop while not pointer is nothing else set n = new node nx = a set n.nextNode = Nothing while pointer.count <> b Set temp = New node Set temp = pointer Set pointer = pointer.nextnode DoEvents Wend Set n.nextnode = pointer Set temp.nextnode = n Set pointer = n Set pointer = head counts = 1 pointer.count = counts Do counts = counts 1 set Pointer = Pointer.nextNode Pointer.count = counts if Objptr (POINTER.NEXTNODE) = Objptr (Head) THEN EXIT DO End If Loop While Not Pointer Is Nothing End IFend Sub