[英]an IXMLDOMAttribute as return value of a VBScript function
I'm creating XML documents with VBScript and MSXML DOM. 我正在使用VBScript和MSXML DOM创建XML文档。 In order to structure and simplify my code I'm using classes and thus methods (functions in VBS) too.
为了结构化和简化我的代码,我也在使用类,因此也使用方法(VBS中的函数)。
Here is a little function that troubles me: 这是一个令我困扰的小功能:
function createAttribute(name, value)
dim doc
Set doc = CreateObject("Msxml2.DOMDocument.4.0")
dim attr
set attr= doc.createNode(2,name,"")
attr.NodeValue=value
createAttribute=attr
end function
The assignment createAttribute=attr
, where I'm setting the return value of the function, causes the following error: 我在其中设置函数的返回值的分配
createAttribute=attr
导致以下错误:
Object doesn't support this property or method
对象不支持此属性或方法
As the web resources on XML processing with VBS are rather sparse, I hope some of you can help me to understand whats going on here. 由于有关使用VBS处理XML的Web资源非常稀疏,我希望你们中的一些人可以帮助我了解这里的情况。 Here are my questions:
这是我的问题:
What object does not support what property or method? 什么对象不支持什么属性或方法?
Can i pass objects of any given class as return values of VBS functions? 我可以将任何给定类的对象作为VBS函数的返回值传递吗?
Can i pass an object of the class IXMLDOMAttribute
as a return value to a VBS function? 我可以将
IXMLDOMAttribute
类的对象作为返回值传递给VBS函数吗?
I think the problem is that attr
is an object, so you need to use set
to apply the return value. 我认为问题在于
attr
是一个对象,因此您需要使用set
来应用返回值。 Otherwise, you may simply be returning attr
's default property value (if it has one): 否则,您可能只是返回
attr
的默认属性值(如果有):
set createAttribute = attr
You don't show how you use the return value, so I can't comment on that but it is possibly the source of the error. 您没有显示如何使用返回值,因此我无法对此进行评论,但这可能是错误的根源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.