請問:為什麼在迴圈內使用變量,在run時有時正常有時錯誤
#include<Excel.au3>Local $sFilePath1 = ("C:\Documents and Settings\Administrator\桌面\輸入格式1.xls")
Local $oExcel= _ExcelBookOpen($sFilePath1)
For $r = 1 to 33
Local $path = _ExcelReadCell($oExcel,1,1)
Select
Case $path = 0
MsgBox(0,"test","0")
Case $path = 1
MsgBox(0,"test","1")
Case $path = 2
MsgBox(0,"test","2")
EndSelect
Next
MsgBox(0,"111","end")
当MSGBOX跳出并显示0时,我再从Excel中把数值改为1
按确定后要执行第二次,就会出现错误。
如附圖。
回复 1# eden_lee
改用关键字试试看........
Switch...Case...EndSwitch 试试#include<Excel.au3>
Local $sFilePath1 = ("C:\Documents and Settings\Administrator\桌面\輸入格式1.xls")
For $r = 1 to 33
Local $oExcel= _ExcelBookOpen($sFilePath1)
Local $path = _ExcelReadCell($oExcel,1,1)
Select
Case $path = 0
MsgBox(0,"test","0")
Case $path = 1
MsgBox(0,"test","1")
Case $path = 2
MsgBox(0,"test","2")
EndSelect
_ExcelBookClose($oExcel)
Next
MsgBox(0,"111","end") 回复 3# tubaba
改用switch方式测试,问题还是一样。
跟上面附图一样。 你改成1后回车了没?没办法读取激活编辑的单元格中的值的
页:
[1]