Private Sub Command1_Click()
Dim i,j As Long
for i=1 to 100
If prime(i) Then
Print i;
j=j+1
if j mod 10=0 then print
end if
next
End Sub
Private Function prime(ByVal n As Long) As Boolean '返回值=True是素数,False不是素数
Dim k As Long
If n < 2 Then
prime = False
Else
prime = True
For k = 2 To n - 1
If (n Mod k) = 0 Then prime = False:Exit For
Next k
End If
End Function