判断一个正整数是否是质数


Private Sub Command1_Click()
   Dim M As Single, I As Single
   M = Inputbox("请输入数")  
   If M = 1 Then
      Print M; "既不是质数也不是合数"
   Else
      If M = 2 Then
         Print M; " 是质数"
      Else
         I = 1
         Do
           I = I + 1
         Loop Until (M Mod I = 0) Or (I = M - 1)
         If M Mod I = 0 Then
            Print M; "不是质数"
         Else
            Print M; "是质数"
         End If
      End If
    End If
End Sub