Private Sub Form_Click()
Dim a
Dim b
Dim c
a = Array(2, 8, 7, 6, 4, 28, 70, 25)
b = Array(79, 27, 32, 41, 57, 66, 78, 80)
For i = 1 To 8 c(i) = a(i) + b(i)
Next i
For i = 1 To 8 Print c(i)
Next i
End Sub
Private Sub Form_Click()
Dim a As Variant'建议说明类型
Dim b As Variant
Dim c(7) As Variant'需要指出这是一个数组
Dim i As Long'变量建设定义一下,加上 option explicit 来强制要求变量定义,可以减少程序因变量名拼写造成的错误
a = Array(2, 8, 7, 6, 4, 28, 70, 25) '下标从0 开始,除非你用 option base 1 指定下标从1开始
b = Array(79, 27, 32, 41, 57, 66, 78, 80)
For i = 0 To 7'下标从 0 起,所以 为 0 to 7 c(i) = a(i) + b(i)
Next i
For i = 0 To 7 '下标从 0 起,所以 为 0 to 7 Print c(i)
Next i
End Sub