需要的控件:
命令按钮,2个,command1,command2
标签,2个,label1,label2
command1代码:
Private Sub Command1_Click()
Dim A(100) As Variant, B As Variant
Dim S As Integer
Dim I As Integer
For I = 1 To 100
A(I) = I
Next
S = 0
For Each B In A()
S = S + B
Next B
Label2.Caption = S
End Sub
command2代码:
Private Sub Command2_Click()
End
End Sub
已经运行过。