我正在尝试从我的代码中返回一个值。只显示代码要容易得多:
Function writeHeaderData() As IXMLDOMNode
Dim xmlDoc As New MSXML2.DOMDocument30
xmlDoc.async = False
xmlDoc.LoadXML "<Foo></Foo>"
Dim Foo As IXMLDOMNode
Set Foo = xmlDoc.DocumentElement
'code snip; includes appending lots of things to Foo
'the error is on this line:
writeHeaderData = Foo
Exit Function
End Function
我已经用谷歌搜索了,但没有用。这个函数是从主子例程调用的,我试图将返回的 IXMLDOMNode 附加到一个更大的函数,但我一直收到一个"Object variable or With block variable not set
“错误” writeHeaderData = Foo
。这是怎么回事?