VB程序中的一点小问题,请大家帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/09 04:15:14
出现如下两个问题:
1.生成结构树 程序段的.Nodes Compile error:Method or data member not found
2.生成物料清单 程序段的 root Compile error:ByRef argument type mismatch

程序如下:
Private conn As New ADODB.Connection
'建立数据库连接
Public Sub OpenConn()
With conn
If .State = adStateClosed Then
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DBPath;Persist Security Info=False"
.Open
End If
End With
End Sub

'打开记录集
Public Function OpenRecordset(ByVal strSql As String) As ADODB.Recordset
Dim rs As New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open strSql, conn, , , adCmdText
End With
Set OpenRecordset = rs
End Function

Dim root As Node

'加载窗体
Private Sub Form_Load()
End Sub

'把Drive1的地址赋给Dir1
Private Sub Drive1_Change()
Form1.Dir1.Path = Form1.Drive1.Drive
End

Dim root As Node
'这句要放在最上面

'加载节点生成结构树及统计零部件数量
Public Sub AddNodes(TableName As String, TNode As Node)
Dim pNode As Node
Dim rs As ADODB.Recordset
Set rs = OpenRecordset("select 名称,有无子结点,数量 from " & TableName)
Do While Not rs.EOF
Set pNode = TreeView1.Nodes.Add(TNode, 4, , rs!名称)
pNode.Tag = rs!数量 * TNode.Tag
If rs!有无子节点 Then
AddNodes rs!名称, pNode
End If
rs.MoveNext
Loop
TNode.Expanded = True
End Sub