问候这一天,

嗨,我是使用 vb 6.0 的初学者。我正在使用以下代码并获得“未定义用户定义的类型”。代码在下面。我得到错误的行被突出显示。请帮忙。我应该添加一些引用或组件吗?如果是,那会是什么。你及时和善意的帮助对我更有帮助

Public Sub LoadDocument()
    Dim xDoc As MSXML2.DOMDocument
    Set xDoc = New MSXML2.DOMDocument
    xDoc.async = False
    xDoc.validateOnParse = False
    If xDoc.Load("C:\Users\284582\Desktop\XML1.xml") Then
            DisplayNode xDoc.ChildNodes, 0
    End If
End Sub

' Error on this line'
Public Sub DisplayNode(ByRef Nodes As MSXML.IXMLDOMNodeList, _
           ByVal Indent As Integer)

    Dim xNode As MSXML.IXMLDOMNode
    Indent = Indent + 2
    For Each xNode In Nodes
        If xNode.NodeType = NODE_TEXT Then

            Debug.Print Space$(Indent) & xNode.ParentNode.nodeName & _
                ":" & xNode.NodeValue
        End If

        If xNode.HasChildNodes Then
            DisplayNode xNode.ChildNodes, Indent
        End If
    Next xNode
End sub

最佳答案

它是 MSXML2.IXMLDOMNodeList ,而不是 MSXML.IXMLDOMNodeList

关于vb6 - 在代码中获取错误为 'User defined type not defined',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13776954/

10-12 01:27