binbin199 发表于 2006-12-12 17:46:34

[求助]VBScript中怎么判断文件末尾呀,老师快来

Sub ReadExternalData
Dim fso, ts, s
Const ForReading = 1
Dim Num1, Num2, Ret
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("c:\data.csv", ForReading)
Open
s = 1
while s <> eof
    s = ts.ReadLine
    if GetCSVCount(s) = 3 then
      Num1 = GetCSVItem(s, 0)
      Num2 = GetCSVItem(s, 1)
      Ret = GetCSVItem(s, 2)
      'msgbox(Num1 & "+" & Num2 & "=" & Ret)
      Call Calc(Num1, Num2, Ret)
    end if
wend
ts.Close
Close
End Sub

我有5条记录,可在读完之后还在继续读,然后就出错说
---------------------------
TestComplete
---------------------------
An exception occurred in the "Unit1" unit at line 50:
Microsoft VBScript 运行时错误
输入超出了文件尾
---------------------------
OK   
---------------------------

请问,这里的while应该怎么写呀,怎么判断文件末尾,拜托了

firefox82 发表于 2006-12-12 19:16:58

好像vbscript里没有eof的吧
Do While ts.AtEndOfLine <> True
    s = ts.ReadLine
    **************
    **************
Loop

yang119345 发表于 2006-12-13 00:37:23

sdlkfj3 火狐狸太牛B了

binbin199 发表于 2006-12-13 12:32:54

谢谢
页: [1]
查看完整版本: [求助]VBScript中怎么判断文件末尾呀,老师快来