|
Sub testmain()
Dim fso1, f1,fso,f
Dim testnumberone,testnumbertwo
Const datafile="D:\calcproject\data\txt\testdata_three.txt"
Const logfile="D:\calcproject\result\testlog.txt"
Set fso1=createobject("Scripting.Filesystemobject")
Set f1=fso1.opentextFile(logfile,8,true)
f1.writeline "Test_ID"+" "+"Testdata"+" "+"Expect result"+" "+"Actualresult"+" "+" testresult"
f1.close
Set f1=nothing
Set fso1=nothing
Set fso=createobject("Scripting.Filesystemobject")
Set f=fso.opentextfile(datafile,1,false) 'readonly if it ont exist ,dom't create it.
Do While f.AtEndOfStream <> True strx=f.readline()//会提示错误
For i=1 to len(strx)
operator=mid(strx,i,1)
Select case operator
Case "+" zz=split(strx,"="):xx=zz(0):expext=zz(1)
cc=split(xx,"+"):testnumberone=cc(0):testnumbertwo=cc(1)
test_fengzhuang one,two,operator,expect
Case "-" zz=split(strx,"="):xx=zz(0):expect=zz(1)
cc=split(strx,"-"):testnumberone=cc(0):testnumbertwo=cc(1)
test_fengzhuangone,two,operator,expect
Case "*" zz=split(strx,"="):xx=zz(0):expect=zz(1)
cc=split(xx,"*"):testnumberone=cc(0):testnumbertwo=cc(1)
test_fengzhuang one,two,operator,expect
Case "/" zz=split(strx,"="):xx=zz(0):expect=zz(1)
cc=split(xx,"*"):testnumberone=cc(0):testnumbertwo=cc(1)
test_fengzhuang one,two,operator,expect
End Select
Next
num=num+1
f.close
Set f=nothing
Set fso=nothing
Loop
End Sub
红色字部分在DO WHILE ... LOOP里,把f关闭了,下一次循环时当然出错了
把关闭文件放到LOOP外面应该就好了
[ 本帖最后由 limengyun326 于 2007-9-9 15:54 编辑 ] |
|