求VB中编写一程序实现求1~100以内所有奇数之和?

2024-12-29 18:42:28
推荐回答(1个)
回答1:

Sub main()
Dim i As Integer
Dim sum As Integer
sum = 0
For i = 1 To 100 Step 1
If i Mod 2 = 1 Then
sum = sum + i
End If
Next
MsgBox sum
End Sub