Private Sub Command1_Click()
Dim M As Integer
Dim N As Integer
Dim flag As Boolean
M = Int(Val(Text1.Text))
N = M - 1
flag = False '为true时表示M可被比它小的整数整除'
While N >= 2
If M Mod N = 0 Then
flag = True
End If
N = N - 1
Wend
If flag = True Then
Print "你不是素数"
Label2.Caption = "你不是素数"
Else
Print "你是素数"
Label2.Caption = "你是素数"
End If
End Sub