如何返回在VBA中传递给它的(Variant)变量的维数 [英] How to return the number of dimensions of a (Variant) variable passed to it in VBA
本文介绍了如何返回在VBA中传递给它的(Variant)变量的维数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
函数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)
循环
Err:
getDimension = i - 1
结束功能
这是我可以想到的唯一方法。不太漂亮…。
看MSDN,他们基本上是一样的。
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….
Looking at MSDN, they basically did the same.
这篇关于如何返回在VBA中传递给它的(Variant)变量的维数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文