且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法访问从VBA中的.net代码返回的对象数组

更新时间:2023-11-04 12:14:58

Dim f as Foo
set f = obj.FooArray(0)

这里有四个错误。 FooArray是一个属性,而不是一个函数。该属性不接受参数。 设置不正确,该属性返回一个数组,而不是对象。 f 的类型是错误的,该属性返回一个数组,而不是单个Foo。这应该更接近:

Four mistakes here. FooArray is a property, not a function. The property doesn't take an argument. Set is incorrect, the property returns an array, not an object. The type for f is wrong, the property returns an array, not a single Foo. This ought to be closer:

Dim f As Foo()
f = obj.FooArray