Dim num, mycount As Integer Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Input #1, num Do num = num + 1 For i = 1 To num If num Mod i = 0 Then mycount = mycount + 1 If mycount > 2 Then mycount = 0: Exit For Next If mycount = 2 Then Print #2, num: Exit Do Loop Loop Until EOF(1) Close #2 Close #1 End End Sub
Dim num, mycount As Integer Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Input #1, num Do num = num + 1 For i = 1 To num If num Mod i = 0 Then mycount = mycount + 1 If mycount > 2 Then mycount = 0: Exit For Next If mycount = 2 Then Print #2, num: mycount = 0: Exit Do Loop Loop Until EOF(1) Close #2 Close #1 End End Sub
Dim s As Boolean Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Until EOF(1) Input #1, x Do x = x + 1 s = False For i = 2 To x \ 2 If x Mod i = 0 Then s = True: Exit For Next Loop Until s = False Print #2, x Loop Close Close End End Sub
Dim y As Boolean Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Input #1, n Do n = n + 1 For i = 2 To n - 1 If n Mod i = 0 Then y = False: Exit For Else y = True Next If y = True Then Exit Do Loop Print #2, n Loop Until EOF(1) Close #2 Close #1 End End Sub
Dim num, mycount As Integer
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do
Input #1, num
Do
num = num + 1
For i = 1 To num
If num Mod i = 0 Then mycount = mycount + 1
If mycount > 2 Then mycount = 0: Exit For
Next
If mycount = 2 Then Print #2, num: Exit Do
Loop
Loop Until EOF(1)
Close #2
Close #1
End
End Sub
程式錯誤
回覆刪除in:
13
13
6
5
6
12
out:
17
17
11
7
11
17
true out:
17
17
7
7
7
13
Dim num, mycount As Integer
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do
Input #1, num
Do
num = num + 1
For i = 1 To num
If num Mod i = 0 Then mycount = mycount + 1
If mycount > 2 Then mycount = 0: Exit For
Next
If mycount = 2 Then Print #2, num: mycount = 0: Exit Do
Loop
Loop Until EOF(1)
Close #2
Close #1
End
End Sub
Dim s As Boolean
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do Until EOF(1)
Input #1, x
Do
x = x + 1
s = False
For i = 2 To x \ 2
If x Mod i = 0 Then s = True: Exit For
Next
Loop Until s = False
Print #2, x
Loop
Close
Close
End
End Sub
Dim y As Boolean
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do
Input #1, n
Do
n = n + 1
For i = 2 To n - 1
If n Mod i = 0 Then y = False: Exit For Else y = True
Next
If y = True Then Exit Do
Loop
Print #2, n
Loop Until EOF(1)
Close #2
Close #1
End
End Sub