Private Sub Form_click() 里的end if 没有块 if 什么意思?

来源:百度知道 编辑:UC知道 时间:2024/05/29 07:32:00
Private Sub Form_click()
Dim i As Integer
s = 0
For i = 2 To 500
If test(i) Then Print i;
s = s + 1
If s Mod 5 = 0 Then Print
End If
Next
End Sub

Public Function test(n As Integer) As Boolean
test = True
For i = 2 To Sqr(n)
If (n Mod i) = 0 Then
test = False
Exit For
End If
Next
End Function

If s Mod 5 = 0 Then Print
End If
这两句有问题,如果你的执行语句直接跟在then后面的话就不要用end if结束。你可以将它们改为
If s Mod 5 = 0 Then Print

If s Mod 5 = 0 Then
Print
End If

If s Mod 5 = 0 Then Print
End If

if前加上else
Private Sub Form_click()
Dim i As Integer
s = 0
For i = 2 To 500
If test(i) Then Print i;
s = s + 1
else If s Mod 5 = 0 Then Print
End If
Next
End Sub 才对

IF是判断语句的开始呗