原始碼:http://down.gogobox.com.tw/t2329175/8r2m2
程式碼:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Num As Long, f As Boolean, x As Long, i As Long
Do
Num = Val(InputBox("請輸入一個要判斷的正整數", ""))
f = True
x = Num \ 2
For i = 2 To x
If (Num Mod i = 0) Then
f = False
Exit For
End If
Next
If f = True Then MsgBox("是質數", 15, "") Else MsgBox("不是質數", 15, "")
Loop While MsgBox("再來一次嗎?", vbYesNo, "") = vbYes
End
End Sub
End Class
'跟VB6還蠻像的呀!


arrow
arrow
    全站熱搜

    讓地獄深紅的天亮 發表在 痞客邦 留言(0) 人氣()