首页上一页 1 下一页尾页 1 条记录 1/1页
VB从入门到精通问题
发表在VB答疑区
2011-06-02
是否精华
是
否
版块置顶:
是
否
在光盘实例中:光盘\TM\sl\12\10的例子中,我把例子重新复制到我新建的文档中进行运行时,怎么出现变量未定义错误Sub tree_add()
TreeView1.Nodes.Clear
Dim mNode As Node
rs1.Open "select * from 部门表 order by 部门编号,编码级次", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then '如果表中有记录
rs1.MoveFirst '将记录指针移到第一条
'使用Do While语句并根据"编码级次"添加不同级别的数据到TreeView控件中
Do While rs1.EOF = False
Select Case rs1.Fields("编码级次")
Case 1
Set mNode = TreeView1.Nodes.Add()
mNode.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode.Key = rs1.Fields("部门全称")
mNode.Image = "close"
Case 2
Set mNode1 = TreeView1.Nodes.Add(mNode.Index, tvwChild)
mNode1.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode1.Key = rs1.Fields("部门全称")
mNode1.Image = "close"
Case 3
Set mNode2 = TreeView1.Nodes.Add(mNode1.Index, tvwChild)
mNode2.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode2.Key = rs1.Fields("部门全称")
mNode2.Image = "close"
Case 4
Set mNode = TreeView1.Nodes.Add(mNode2.Index, tvwChild)
mNode3.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode3.Key = rs1.Fields("部门全称")
mNode3.Image = "close"
Case 5
Set mNode4 = TreeView1.Nodes.Add(mNode3.Index, tvwChild)
mNode4.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode4.Key = rs1.Fields("部门全称")
mNode4.Image = "close"
End Select
rs1.MoveNext
Loop
End If
rs1.Close
End Sub
mNode1,mNode2,mNode3,mNode4未定义
TreeView1.Nodes.Clear
Dim mNode As Node
rs1.Open "select * from 部门表 order by 部门编号,编码级次", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then '如果表中有记录
rs1.MoveFirst '将记录指针移到第一条
'使用Do While语句并根据"编码级次"添加不同级别的数据到TreeView控件中
Do While rs1.EOF = False
Select Case rs1.Fields("编码级次")
Case 1
Set mNode = TreeView1.Nodes.Add()
mNode.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode.Key = rs1.Fields("部门全称")
mNode.Image = "close"
Case 2
Set mNode1 = TreeView1.Nodes.Add(mNode.Index, tvwChild)
mNode1.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode1.Key = rs1.Fields("部门全称")
mNode1.Image = "close"
Case 3
Set mNode2 = TreeView1.Nodes.Add(mNode1.Index, tvwChild)
mNode2.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode2.Key = rs1.Fields("部门全称")
mNode2.Image = "close"
Case 4
Set mNode = TreeView1.Nodes.Add(mNode2.Index, tvwChild)
mNode3.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode3.Key = rs1.Fields("部门全称")
mNode3.Image = "close"
Case 5
Set mNode4 = TreeView1.Nodes.Add(mNode3.Index, tvwChild)
mNode4.Text = "(" & rs1.Fields("本级编号") & ")" & rs1.Fields("部门名称")
mNode4.Key = rs1.Fields("部门全称")
mNode4.Image = "close"
End Select
rs1.MoveNext
Loop
End If
rs1.Close
End Sub
mNode1,mNode2,mNode3,mNode4未定义