VB提示 实时错误‘62’ 输入超出文件尾 怎么解决

Dim i As Integer
Dim s As String
Open App.Path & "\123.txt" For Input As #1

For i = 1 To Text2.Text
Line Input #1, s
Next i

Text3.Text = s

Close #1
当读取完TXT里面的内容之后, 再运行就提示实时错误62. 请问如何修改下, 不想用On Error Resume Next, 当读取完内容之后, 弹出MsgBox“数据已读取完毕”, 如何修改?

Dim i As Integer
Dim s As String
Open App.Path & "\123.txt" For Input As #1
For i = 1 To Val(Text2.Text)
If Not EOF(1) Then Line Input #1, s
Next i
Text3.Text = s
Close #1
MsgBox "数据已读取完毕"
温馨提示:答案为网友推荐,仅供参考
相似回答