vb6 Treeview1 问题将状态添加到 For 语句

vb6 Treeview1 Question Add Status to For Statement

For 语句我想添加一个状态,让我知道它已在下面代码中显示的这一行完成。

Private Sub Command21_Click()
    Dim NodX As Node
    Dim NodX2 As Node
    Dim ii As Integer
    Dim iCounter As Integer

    On Error Resume Next
    For Each NodX In TreeView1.Nodes
        ii = NodX.Index
        If NodX.Image = 4 Then
            ' Check for Children
            If NodX.Children > 0 Then
                ' Get first Child
                Set NodX2 = NodX.Child
                ' Loop through all children
                For iCounter = 1 To NodX.Children
                    ' Set image to 3 if it was 5
                    If NodX2.Image = 5 And NodX2.Parent.Image = 4 Then
                        NodX2.Image = 3
                    End If    

                    'If NodX2.Image = 3 And NodX2.Parent.Image = 4 Then NodX2.Parent.Image = 9
                    ' Get next node
                    Set NodX2 = NodX2.Next
                Next
            End If
            If TreeView1.Nodes(NodX2.Index).Index = TreeView1.Nodes.Count - 0 Then
                'Label3.Caption = "done"
                'Call Command5_Click
                'Exit For
            End If
        End If
    Next
End Sub

你看到了吗NodX2.Image = 3我需要在这里添加一些代码让我知道它已经完成了所有添加所以label3.caption = "done"

只需在 Sub 的末尾添加 label3.caption = "done",就在最后一个 Next 之后。

Private Sub Command21_Click()
    Dim NodX As Node
    Dim NodX2 As Node
    Dim ii As Integer
    Dim iCounter As Integer

    On Error Resume Next
    For Each NodX In TreeView1.Nodes
        ii = NodX.Index
        If NodX.Image = 4 Then
            ' Check for Children
            If NodX.Children > 0 Then
                ' Get first Child
                Set NodX2 = NodX.Child
                ' Loop through all children
                For iCounter = 1 To NodX.Children
                    ' Set image to 3 if it was 5
                    If NodX2.Image = 5 And NodX2.Parent.Image = 4 Then
                        NodX2.Image = 3
                    End If    

                    'If NodX2.Image = 3 And NodX2.Parent.Image = 4 Then NodX2.Parent.Image = 9
                    ' Get next node
                    Set NodX2 = NodX2.Next
                Next
            End If
            If TreeView1.Nodes(NodX2.Index).Index = TreeView1.Nodes.Count - 0 Then
                'Label3.Caption = "done"
                'Call Command5_Click
                'Exit For
            End If
        End If
    Next
Call Command5_Click
End Sub

非常感谢**

Étienne Laneville

**