如何返回在 VBA 中传递给它的(变体)变量的维数 [英] How to return the number of dimensions of a (Variant) variable passed to it in VBA
本文介绍了如何返回在 VBA 中传递给它的(变体)变量的维数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道如何在 VBA 中返回传递给它的 (Variant) 变量的维数?
Does anyone know how to return the number of dimensions of a (Variant) variable passed to it in VBA?
推荐答案
Function getDimension(var As Variant) As Long
On Error GoTo Err
Dim i As Long
Dim tmp As Long
i = 0
Do While True
i = i + 1
tmp = UBound(var, i)
Loop
Err:
getDimension = i - 1
End Function
这是我唯一能想到的方法.不漂亮….
That's the only way I could come up with. Not pretty….
查看 MSDN,他们基本上是这样做的.
Looking at MSDN, they basically did the same.
这篇关于如何返回在 VBA 中传递给它的(变体)变量的维数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文