Private Sub Form_Click()
Dim a As Integer, i As Integer, sum As Integer
a = InputBox("输入一个大于1的奇数")
For i = 1 To a
If i Mod 2 = 1 Then
sum = sum + i
Print i;
End If
Next
Print "和:" + CStr(sum)
End Sub
Private Sub Command1_Click()
Dim n As Single, s As Single, i As Single
n = 22
For i = 1 To n Step 2
s = s + i
Next
Print s
End Sub
s是1~n所有奇数相加的值
dim sum as long
for i=1 to n
sum=sum+i
next i
print sum