在Visual Basic中使用循环向数组添加不同的值

时间:2017-03-13 12:30:12

标签: arrays vba loops

我正在尝试向数组中添加一些值:

Dim i As Integer   
Dim numlist(5) As Double  

Dim num201401 As Double  
Dim num201402 As Double  
Dim num201403 As Double  
Dim num201404 As Double  
Dim num201405 As Double  
Dim num201406 As Double  

num201401 = 5  
num201402 = 7  
num201403 = 9  
num201404 = 8  
num201405 = 3  
num201406 = 10  

For i = 0 To 5  
    numlist(i) = num(20140+&i)  -->(This part is my question)  
Next 

如何在i和我的值之间分配连接(num201401到num201406)?

1 个答案:

答案 0 :(得分:0)

为什么要尝试将变量分配给数组?

你可以这样做:

Dim numlist(5) as Double

numlist(0) = 5
numlist(1) = 7
.
.
.

Here解释了如何处理数组。