VB 利用for each...next循环语句,求 1+2+3+...+100的值 。
1个回答
展开全部
需要的控件:
命令按钮,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
已经运行过。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询