Private Sub cmdCommand1_Click()
Dim i As Integer, j As Integer, num As Integer, Str As String, b As Boolean
For i = 101 To 199
b = True
For j = 2 To Sqr(i)
If i Mod j = 0 Then
b = False
Exit For
End If
Next
If b Then
num = num + 1
Str = Str & " " & i
End If
Next
Debug.Print Str
Print "质数个数: " & num
End Sub
可以看看我的文章:
http://hi.baidu.com/syx54/item/5eabf5dc8ccc2c1fd80e441e