本文介绍了请更正我的vb 6编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub Form_Activate()
    Dim nodX As Node
    Set nodX = TreeView1.Nodes.Add(, , "root", "Chart")
    Set nodX = TreeView1.Nodes.Add("root", tvwChild, "child1", "Details")

    Set RS1  = New ADODB.Recordset
    RS1.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=1", CON, adOpenKeyset, adLockOptimistic
    If RS1.RecordCount > 0 Then
        Dim C
        C = 1
        RS1.MoveFirst
        Do Until RS1.EOF
            Set nodX = TreeView1.Nodes.Add("child1", tvwChild, "child1-" & C & RS1!CODE, RS1!BUYER_NAME)
            Set RS2  = New ADODB.Recordset
            RS2.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=2", CON, adOpenKeyset, adLockPessimistic
            If RS2.RecordCount > 0 Then
                Dim D
                D = 1
                RS2.MoveFirst
                Do Until RS2.EOF
                    Set nodX = TreeView1.Nodes.Add("child1-" & C & RS1!CODE, tvwChild, "child1-" & C & "-" & D & RS2!CODE, RS2!BUYER_NAME)
                    Set RS3  = New ADODB.Recordset
                    RS3.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=3", CON, adOpenKeyset, adLockOptimistic
                    If RS3.RecordCount > 0 Then
                        Dim E
                        E = 1 
                        RS3.MoveFirst
                        Do Until RS3.EOF
                            Set nodX = TreeView1.Nodes.Add("child1-" & C & "-" & D & RS2!CODE, tvwChild, "child1-" & C & "-" & D & "-" & E & RS3!CODE, RS3!BUYER_NAME)
                            Set RS4  = New ADODB.Recordset
                            RS4.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=4", CON, adOpenKeyset, adLockOptimistic
                            If RS4.RecordCount > 0 Then
                                Dim F
                                F = 1
                                RS4.MoveFirst
                                Do Until RS4.EOF
                                    Set nodX = TreeView1.Nodes.Add("child1-" & C & "-" & D & "-" & E & RS3!CODE, tvwChild, "child1-" & C & "-" & D & "-" & E & "-" & F & RS4!CODE, RS4!BUYER_NAME)
                                    F = F + 1
                                    RS4.MoveNext
                                Loop
                            End If
                            RS4.Close
                            Set RS4 = Nothing
                            E = E + 1
                            RS3.MoveNext
                        Loop
                    End If
                    RS3.Close
                    Set RS3 = Nothing
                    D = D + 1
                    RS2.MoveNext
                Loop
            End If
            RS2.Close
            Set RS2 = Nothing
            C = C + 1
            RS1.MoveNext
        Loop
    End If
    RS1.Close
    Set RS1 = Nothing
End Sub

推荐答案



这篇关于请更正我的vb 6编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 23:03