VB中显示红色部分“变量未定义”什么意思?着急啊
下面红色部分总是提示“变量未定义”我用的是VB6.0Treeview控件也添加了Microsoft windows common controls5.0.不知道缺少了什么
Option Explicit
Private Sub Form_Load()
Dim rec As New ADODB.Recordset
Dim strecsql As String
Dim Item As Integer
Dim i As Integer
Dim nodex As Node
Set nodex = TreeView.Nodes.Add(, , "爷", "销售客户", "k1", "k2")
nodex.Sorted = True
rec.Open "大区表", currentproject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To rec.RecordCount - 1
Set nodex = TreeView.Nodes.Add("爷", tvwChild, "父" & rec.Fields("大区ID"), rec.Fields("大区名称"), "k1", "k2")
nodex.Selected = True
rec.MoveNext
Next
rec.Close
'设置第三级树
rec.Open "省份表", currentproject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To rec.RecordCount - 1
Set nodex = TreeView.Nodes.Add("父" & rec.Fields("所属大区"), tvwChild, "子" & rec.Fields("省份ID"), rec.Fields("省份名称"), "k1", "k2")
nodex.Sorted = True
rec.MoveNext
Next
rec.Clone
'设置第四级树
rec.Open "客户表", currentproject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To rec.RecordCount - 1
Set nodex = TreeView.Nodes.Add("子" & rec.Fields("所属省份"), tvwChild, "孙" & rec.Fields("客户ID"), rec.Fields("客户名称"), "k1", "k2")
nodex.Sorted = True
rec.MoveNext
Next
rec.Close
End Sub
vb treeview 控件
[解决办法]
你画一个 TreeView 控件上去,它的默认名字是: TreeView1
你没更改,后面就多了个 1 。