[英]What's difference between working with arrays declared as Dim Array() as Variant and Dim Array as Variant in VBA?
What's difference between two declarations Dim Array_1() as Variant
and Dim Array_2 as Variant
in VBA ? 在VBA中,两个声明
Dim Array_1() as Variant
和Dim Array_2 as Variant
声明有什么区别?
If I then create arrays using above declarations : 如果我然后使用上述声明创建数组:
Array_1 = Range("A1:A10")
Array_2 = Range("A1:A10")
in locals windows I see different descriptions for Array_1 and Array_2. 在本地窗口中,我看到关于Array_1和Array_2的不同描述。 I seems that Array_2 contain values of undefined type.
我似乎Array_2包含未定义类型的值。 Could I
ReDim
Array_2
? 我可以
ReDim
Array_2
吗?
Dim Arraytest() as Variant
Declare's a variable called Arraytest which is setup as an array The above can be used like below 声明一个名为Arraytest的变量,该变量设置为数组上面的代码可以像下面这样使用
ReDim Arraytest(9)
or 要么
ReDim Arraytest(1 To 10)
To setup an array of 10 values - Arraytest(0) to Arraytest(9) in the first case and Arraytest(1) to Arraytest(10) in the second case. 要设置10个值的数组-第一种情况为Arraytest(0)至Arraytest(9),第二种情况为Arraytest(1)至Arraytest(10)。
As opposed to : 相对于:
Dim Arraytest as Variant
Declare's a variable called Arraytest which is setup as a single varaible - note the second code can not be used as an array 声明一个名为Arraytest的变量,该变量设置为单个变量-请注意,第二个代码不能用作数组
Note: Array can not be used as a variable name - used Arraytest in the above 注意:数组不能用作变量名-上面使用了Arraytest
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.