请教一段vb的代码

来源:百度知道 编辑:UC知道 时间:2024/05/15 16:53:19
Dim arrPrices(1 to 10)
Dim i As Integer
For i = 1 to 10
arrPrices(i)= i * 2
Next i
MSChart1.ChartData = arrPrices
----------------------------------------------------------------
中的
For i = 1 to 10
arrPrices(i)= i * 2
Next i
是什么意思?

Dim arrPrices(1 to 10)
因此数组arrPrices有10个元素,从1到10

那么:
For i = 1 to 10
arrPrices(i)= i * 2
Next i
就是分别让数组arrPrices的1到10的元素中的值分别等于对应的i*2的值..

展开后就是:

arrPrices(1)= 2

arrPrices(2)= 4
arrPrices(3)= 6
....
..
arrPrices(10)= 20

以上的是正解