Private Sub Command1_Click()
Dim n As Integer, i As Integer
n = Val(Text1.Text)
For i = 2 To n - 1
If n Mod i = 0 and i<=n-1Then
MsgBox (n & "不是素数")
Exit For
Next i
End If
If i > n - 1 Then
MsgBox (n & "是素数")
End If
End Sub
Dim n As Integer, i As Integer
n = Val(Text1.Text)
For i = 2 To n - 1
If n Mod i = 0 and i<=n-1Then
MsgBox (n & "不是素数")
Exit For
Next i
End If
If i > n - 1 Then
MsgBox (n & "是素数")
End If
End Sub