vba 如何在VBA中确定数组的长度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44438459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 12:42:29 来源:igfitidea点击:
How to determine the length of an array in VBA
提问by Edward de Goeij
I have an array that looks like this:
我有一个看起来像这样的数组:
students1 = Array(423.5482, 425.6641)
Now I would like to get the length of this array. However, if I try this:
现在我想得到这个数组的长度。但是,如果我尝试这样做:
MsgBox(students1.Length)
I get the error that an object is required. Any thoughs on how I can get the length?
我收到需要对象的错误。关于如何获得长度的任何想法?
回答by Scott Craner
Use UBound and and Lbound
使用 Ubound 和 Lbound
MsgBox Ubound(students1)-Lbound(students1)+1