全国计算机等级考试二级VB,关于当循环?

来源:百度知道 编辑:UC知道 时间:2024/06/13 23:26:44
现在在窗体上建立两个文本框,一个命令按钮.在命令按钮的单击事件中,编写程序代码..
Private Sub Command1_Click()
Dim x As Integer, i As Integer
x = Val(Text1)

For i = 2 To x - 1
If x Mod i = 0 Then
Exit For
End If
Next i
If i >= x Then
Text2 = "是素数"
Else
Text2 = "不是素数"
End If
End Sub
现在想把当中的For循环改成当循环,请问该如何写程序代码??

Private Sub Command1_Click()
Dim x As Integer, i As Integer
x = Val(Text1)
i=2
while i < x
if x mod = 0 then
break
end if
i=i+1
loop
If i >= x Then
Text2 = "是素数"
Else
Text2 = "不是素数"
End If
End Sub