Private Sub Form_Click() Dim n As Integer, i As Integer, sum As Integer n = Val(InputBox("请输入个数N:", "输入", 5)) For i = 1 To n sum = sum + i * 2 - 1 Next Print sum End Sub
Private Sub Form_Click() Dim x As Integer Dim y As Integer x = InputBox("输入", , 5) For y = x To 1 Step -1 If y Mod 2 <> 0 Then k = k + y End If Next y Print k End Sub