|
以下为从文本读一位数相加的代码
'Option explicit
Dim Fso,TheFile,ReadString
Dim TestNumberOne,TestNumberTwo
Dim ipos,iLen
Const ForReading=1
Set Fso=createobject("Scripting.FileSystemObject")
Set TheFile= Fso.OpenTextFile("F:\test\VB calc\testNumber.txt",ForReading,False)
Do while TheFile.atendofline<>true
ReadString=TheFile.ReadLine
ipos=instr(1,ReadString,",",1)
iLen=Len(ReadString)
TestNumberOne=Left(ReadString,ipos-1)
TestNumberTwo=Right(ReadString,iLen-ipos)
msgbox "TestNumberOne=" & TestNumberOne
msgbox "TestNumberTwo=" & TestNumberTwo
Window("计算器").WinButton(TestNumberOne).Click
Window("计算器").WinButton("+").Click
Window("计算器").WinButton(TestNumberTwo).Click
Window("计算器").WinButton("=").Click
Loop
TheFile.close
Set TheFile=nothing
Set Fso=nothing
去掉msgbox可正常运运,但加上后,却时而能运行,时而不能运行。是什么原因? |
|