我的treeview代码错在哪?
Dim rs1 As New ADODB.Recordset '定义数据集对象
Private nod As Node
-------------------------------------------------------------------------
Private Sub Form_Load()
Dim key, text As String
Dim nod As Node
Adodc1.RecordSource = "select * from p_xlkind order by spxlcode"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
If Len(Trim(Adodc1.Recordset.Fields("spxlcode"))) = 2 Then
key = Trim(Adodc1.Recordset.Fields("spxlcode"))
text = "(" & Trim(Adodc1.Recordset.Fields("spxlcode")) & ")" & Trim(Adodc1.Recordset.Fields("sspxl"))
Set node1 = TreeView1.Nodes.Add(, , key, text, 1)
End If '运行这个地方报错,说无效关键字
If Len(Trim(Adodc1.Recordset.Fields("spxlcode"))) = 4 Then
key = Trim(Adodc1.Recordset.Fields("spxlcode"))
text = "(" & Trim(Adodc1.Recordset.Fields("spxlcode")) & ")" & Trim(Adodc1.Recordset.Fields("sspxl"))
Set Node2 = TreeView1.Nodes.Add(node1.Index, tvwChild, key, text, 2)
End If
If Len(Trim(Adodc1.Recordset.Fields("spxlcode"))) = 6 Then
key = Trim(Adodc1.Recordset.Fields("spxlcode"))
text = "(" & Trim(Adodc1.Recordset.Fields("spxlcode")) & ")" & Trim(Adodc1.Recordset.Fields("sspxl"))
Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, key, text, 3)
End If
Adodc1.Recordset.MoveNext
Loop
End If
End Sub
[此贴子已经被作者于2005-8-9 10:31:53编辑过]