首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

关于运行时异常

2012-01-29 
关于运行时错误我用vb写的软件一直运行很正常,今天突然出现了奇怪的错误:运行时错误‘62’ 输入超出文件尾。

关于运行时错误
我用vb写的软件一直运行很正常,今天突然出现了奇怪的错误:运行时错误‘62’ 输入超出文件尾。

'写入
Open "myfile.txt" For Output As #1
Print #1, s 's为你要写入的值
Close #1
'读取
Open "myfile.txt" For Input As #1
Line Input #1, s 's存储你要读取的值
Close #1

问题好像出在了myfile.txt中为空了,我每次都用上述代码写入读取变化的数字,怎么会变空呢?



[解决办法]

strMemo = ""
intFileNum = FreeFile(0)
Open strFile For Input As #intFileNum
Do While Not EOF(intFileNum)
Line Input #intFileNum, strMemo
txtMemo.Text = txtMemo.Text & strMemo & vbCrLf
Loop
Close #intFileNum
[解决办法]
1楼正解 加文件长度判断

热点排行