1、程序功能:求1到400间,同时能被3和7整除的数的个数。程序中有一处错误。改正错误,使它能输出正确的结果。
Private Sub Form_Click()
Dim count As Integer
Dim x As Integer
For x = 1 To 400
'下一行程序有错
If Mod(x, 3) = 0 And Mod(x, 7) = 0 Then
count = count + 1
End If
Next x
Print count
End Sub
2、程序功能:求200到400间,能被3整除但不能被7整除的数的个数。程序中有错误。改正错误,使它能输出正确的结果。
Private Sub Command1_Click()
Dim count As Integer
Dim x As Integer
count = 0
x = 200
While x <= 400
If x Mod 3 = 0 And x Mod 7 <> 0 Then
count = count + 1
End If
x = x + 1
'下一行程序有错
Loop
If x Mpd 3 = 0 And x, Mod 7 = 0 Then
Loop
->
Wend