下标越界.为什么?[已角决]
代码如下,加红色部份提示下标越界.....Private Sub Form_Load()
Me.WindowState = 2 '窗体最大化
'连接数据库
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\data\yxhmk.mdb;Persist Security Info=False"
TreeView1.ImageList = 树状图标 '设置树状控件的图标
'===========================================设置树状控件的第一级节点
Adodc1.RecordSource = "使用单位" '<-------------连接数据库里的<表>
Adodc1.Refresh '<-----------------------刷新连接
II = Adodc1.Recordset("使用单位")
Set Node1 = TreeView1.Nodes.Add(, , "root", II, 1)
'===========================================设置树状控件的第二级节点
Adodc1.RecordSource = "线路档案" '连接数据库里的<表>
Adodc1.Refresh '刷新连接
Adodc1.Recordset.MoveLast '记录集指钉到达最后一条
Adodc1.Recordset.MoveFirst '记录集指钉到达第一条
M = Adodc1.Recordset.RecordCount '获得记录集的总条数
ReDim X(M) As String, Y(M) As String
For I = 1 To M
X(I) = Adodc1.Recordset("线路编号")
Y(I) = Adodc1.Recordset("线路名称")
Set Node1 = TreeView1.Nodes.Add("root", tvwChild, "A" & X(I), Y(I), 2, 5)
Adodc1.Recordset.MoveNext
Next
'===========================================设置树状控件的第三级节点
Adodc1.RecordSource = "台区档案"
Adodc1.Refresh
Do While Adodc1.Recordset.EOF = False
A = Adodc1.Recordset("所属线路")
I2 = Adodc1.Recordset("台区编号")
Set Node1 = TreeView1.Nodes.Add("A" & X(A), tvwChild, "A" & I2, Adodc1.Recordset("台区名称"), 3, 5)
Adodc1.Recordset.MoveNext
Loop
'===========================================设置树状控件的第四级节点
Adodc1.RecordSource = "用户档案"
Adodc1.Refresh
Do While Adodc1.Recordset.EOF = False
K = Adodc1.Recordset("所属台区")
G = Adodc1.Recordset("用户编号")
Set Node1 = TreeView1.Nodes.Add("A" & [bo]X(K), [/bo]tvwChild, "A" & G, Adodc1.Recordset("用户名称"), 3, 5)
Adodc1.Recordset.MoveNext
Loop
End Sub
附件:[
[[it] 本帖最后由 yxhmk 于 2008-9-3 11:51 编辑 [/it]]