Dim n As Integer, ansPrivate Sub Form_Load()Me.HideOpen App.Path & "\in.txt" For Input As #1Open App.Path & "\out.txt" For Output As #2Input #1, nIf n > 1 Then ans = n - 1If n = 1 Then ans = 1Print #2, ansCloseCloseEndEnd Sub應該是這樣沒錯
Dim n As LongPrivate Sub Form_Load()Me.HideOpen App.Path & "\in.txt" For Input As #1Open App.Path & "\out.txt" For Output As #2Input #1, nIf n > 1 Then ans = n - 1If n = 1 Then ans = 1Print #2, ansClose #2Close #1EndEnd Sub
Dim n As Integer, ans
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
If n > 1 Then ans = n - 1
If n = 1 Then ans = 1
Print #2, ans
Close
Close
End
End Sub
應該是這樣沒錯
Dim n As Long
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
If n > 1 Then ans = n - 1
If n = 1 Then ans = 1
Print #2, ans
Close #2
Close #1
End
End Sub