一道VB习题,求答案
题目:输出101到500之间的所有奇数,每行显示10个奇数,并输出奇数之和。要详尽的可以执行的程序代码,谢谢,OK的追加分哦~谢谢各位啦...
题目:输出101到500之间的所有奇数,每行显示10个奇数,并输出奇数之和。要详尽的可以执行的程序代码,谢谢,OK的追加分哦~谢谢各位啦
展开
2个回答
展开全部
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim s As Long
j = 0
s = 0
Me.AutoRedraw = True '自动重画,显示结果
For i = 101 To 500
If i Mod 2 = 1 Then
Me.Print i;
s = s + i
j = j + 1
If j = 10 Then
Me.Print
j = 0
End If
End If
Next i
Me.Print
Me.Print "SUM="; s
End Sub
调试通过
Dim i As Integer
Dim j As Integer
Dim s As Long
j = 0
s = 0
Me.AutoRedraw = True '自动重画,显示结果
For i = 101 To 500
If i Mod 2 = 1 Then
Me.Print i;
s = s + i
j = j + 1
If j = 10 Then
Me.Print
j = 0
End If
End If
Next i
Me.Print
Me.Print "SUM="; s
End Sub
调试通过
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询