作业帮 > 综合 > 作业

VB 利用for each...next循环语句,求 1+2+3+...+100的值 .

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/05 10:47:29
VB 利用for each...next循环语句,求 1+2+3+...+100的值 .
需要的控件:命令按钮,2个,command1,command2标签,2个,label1,label2command1代码: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 Subcommand2代码:Private Sub Command2_Click()
    End
End Sub已经运行过.