Private Sub Command1_Click()
Dim n As Integer, i As Integer
Dim flag As Boolean ‘用于标记是否为素数
Randomize
n = Int( ① )*2+1
Text1.Text = Str(n)
flag = True ‘标记为素数
i = 3
Do While i <= n - 1 And flag = True
If n Mod i = 0 Then
flag = False
End If
i = i + 2
Loop
If ② Then
Text2.Text = Str(n) + “是素数”
Else
Text2.Text = Str(n) + “不是素数”
End If
End Sub
① ②