变量数组可以有0个元素吗?

时间:2022-05-24 15:42:21

The normal dynamic array supports empty (= nil, Length() = 0).

普通的动态数组支持empty(= nil,Length()= 0)。

The variant array however does not seem to support this.

然而,变体数组似乎不支持这一点。

I pass my data in variant array (because of OLE/COM), and I get an error when the user defines 0 elements...

我在变量数组中传递我的数据(因为OLE / COM),当用户定义0个元素时我收到错误...

I can use varEmpty instead of a 0 length array, but these data arrays are flexible changed (add item, remove item, etc.).

我可以使用varEmpty而不是0长度数组,但这些数据数组是灵活更改的(添加项目,删除项目等)。

How I can I pass empty arrays in a Variant, or do I need to use other way?

我如何在Variant中传递空数组,还是需要使用其他方式?

1 个解决方案

#1


5  

varEmpty is the correct way to handle this. Of course, the code on the other side of the COM interface may not like empty arrays, but that all depends on the particular contract you have with that interface.

varEmpty是处理此问题的正确方法。当然,COM接口另一端的代码可能不喜欢空数组,但这一切都取决于您对该接口的特定合同。

#1


5  

varEmpty is the correct way to handle this. Of course, the code on the other side of the COM interface may not like empty arrays, but that all depends on the particular contract you have with that interface.

varEmpty是处理此问题的正确方法。当然,COM接口另一端的代码可能不喜欢空数组,但这一切都取决于您对该接口的特定合同。