1、Private Sub Command1_Click()Dim n As IntegerDim i As IntegerDim f As Booleann = Val(Text1.Text)f = TrueFor i = 2 To n - 1If n Mod i = 0 Thenf = FalseEnd IfNextIf f = True ThenText2.Text = “素数“ElseText2.Text = “不是素数 “End IfEnd SubPrivate Sub Command1_Click()Dim n As IntegerDim i As IntegerDim f As Bo
2、oleann = Val(Text1.Text)f = TrueFor i = 2 To n - 1If n Mod i = 0 Then f = FalseNextIf f ThenText2.Text = “素数“ElseText2.Text = “不是素数 “End IfEnd SubPrivate Sub Command1_Click()Dim n As IntegerDim i As IntegerDim f As Booleann = Val(Text1.Text)f = TrueFor i = 2 To n - 1If n Mod i = 0 Thenf = FalseExit
3、ForEnd IfNextIf f ThenText2.Text = “素数“ElseText2.Text = “不是素数 “End IfEnd SubPrivate Sub Command1_Click()Dim n As IntegerDim i As Integern = Val(Text1.Text)For i = 2 To n - 1If n Mod i = 0 ThenExit ForEnd IfNextIf i = n ThenText2.Text = “素数“ElseText2.Text = “不是素数 “End IfEnd SubPrivate Sub Command1_Click()Dim n As IntegerDim i As Integern = Val(Text1.Text)For i = 2 To Int(Sqr(n)If n Mod i = 0 ThenExit ForEnd IfNextIf i Int(Sqr(n) ThenText2.Text = “素数“ElseText2.Text = “不是素数 “End IfEnd Sub