Excel 学习VBA数组,怎么通过数组传递

发布网友 发布时间:2022-04-25 20:41

我来回答

1个回答

热心网友 时间:2022-06-17 06:01

数组作为入参的例子如下:
按地址传递byref
Sub AAATest()
Dim StaticArray(1 To 3) As Long
Dim N As Long
StaticArray(1) = 1
StaticArray(2) = 2
StaticArray(3) = 3
PopulatePassedArray Arr:=StaticArray
For N = LBound(StaticArray) To UBound(StaticArray)
Debug.Print StaticArray(N)
Next N
End Sub

Sub PopulatePassedArray(ByRef Arr() As Long) 这里是数组入参
Dim N As Long
For N = LBound(Arr) To UBound(Arr)
Arr(N) = N * 10
Next N
End Sub

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com