Rs.Open "select * from tableMB where cla=1 and upkey<>0 and upkey<>'" & TabKey(IntKey) & "' and result='" & TabKey(IntKey) & "' and chose=1 order by xkey", Ocn, adOpenDynamic, adLockReadOnly
Do Until Rs.EOF
Set ds = TView.Nodes.Add("key" + Trim(Str(Rs.Fields!upkey)), 4, "key" + Trim(Str(Rs.Fields!xkey)), Rs.Fields!xname)
Rs.MoveNext
IntNo = IntNo + 1
Loop
Rs.Close
TmpLeft = 120
IntTop = 200
IntLeft = 120
TviewNo = 1
SSTab.Tab = IntKey
Load Pic(IntKey + 1)
Pic(IntKey + 1).Width = Pic(0).Width
Pic(IntKey + 1).Height = Pic(0).Height
Pic(IntKey + 1).Container = SStab
StartNo(IntKey) = TviewIndex + 1
Do Until IsEnd = True
Load Lab(TviewIndex + 1)
Lab(TviewIndex + 1).Caption = TView.Nodes(TviewNo).Text
Lab(TviewIndex + 1).Top = IntTop
Lab(TviewIndex + 1).Left = IntLeft
Lab(TviewIndex + 1).Container = Pic(IntKey + 1)
Lab(TviewIndex + 1).Visible = True
Load Com(TviewIndex + 1)
Com(TviewIndex + 1).Top = IntTop - 50
Com(TviewIndex + 1).Left = IntLeft + 1000
Com(TviewIndex + 1).Container = Pic(IntKey + 1)
If TView.Nodes(TviewNo).Children > 0 Then
Com(TviewIndex + 1).Visible = False
IntLeft = IntLeft + 1250
TmpLeft = IntLeft
TviewNo = TView.Nodes(TviewNo).Child.Index
Else
Com(TviewIndex + 1).Visible = True
If Not (TView.Nodes(TviewNo).Next Is Nothing) Then
TviewNo = TView.Nodes(TviewNo).Next.Index
IntLeft = IntLeft + Com(TviewIndex + 1).Width + 1100
If IntLeft > 10000 - 1000 Then
IntLeft = TmpLeft
IntTop = IntTop + 350
End If
Else
IntTop = IntTop + 500
If Not (TView.Nodes(TviewNo).Parent Is Nothing) Then
If Not (TView.Nodes(TviewNo).Parent.Next Is Nothing) Then
IntLeft = TmpLeft - 1250
TviewNo = TView.Nodes(TviewNo).Parent.Next.Index
End If
Else
IsEnd = True
End If
End If
End If
TviewIndex = TviewIndex + 1
Loop
EndNo(IntKey) = TviewIndex
Pic(IntKey + 1).Visible = True
TabKey(IntKey) = 0
IsEnd = False