代码如下:Dim TmpFile As String, TmpStr As String
Dim StrIndex As Integer
Dim cmdstr
Dim count As String
Dim sFile As Variant
TmpFile = App.Path & "\ip.txt"
If Dir(TmpFile) <> "" Then Kill TmpFile
cmdstr = "cmd /c ping " & IP & ">" & TmpFile
Shell cmdstr, vbHide
Open TmpFile For Input As #1 <--------------
Do Until EOF(1)
.....
我用F8单步调试OK,但用F5执行时在Open TmpFile For Input As #1出现file not found的错误,我在文件中可能找到这处文件
这是什么原因,请高手指点
Dim StrIndex As Integer
Dim cmdstr
Dim count As String
Dim sFile As Variant
TmpFile = App.Path & "\ip.txt"
If Dir(TmpFile) <> "" Then Kill TmpFile
cmdstr = "cmd /c ping " & IP & ">" & TmpFile
Shell cmdstr, vbHide
Open TmpFile For Input As #1 <--------------
Do Until EOF(1)
.....
我用F8单步调试OK,但用F5执行时在Open TmpFile For Input As #1出现file not found的错误,我在文件中可能找到这处文件
这是什么原因,请高手指点
如果不在,要保证他们是在同一文件夹下
'而单步执行的时候,有时间停留,所以shell命令已经执行完毕。
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Dim StrIndex As Integer
Dim cmdstr
Dim count As String
Dim sFile As Variant
TmpFile = App.Path & "\ip.txt"
If Dir(TmpFile) <> "" Then Kill TmpFile
cmdstr = "cmd /c ping " & IP & ">" & TmpFile
Shell cmdstr, vbHidesleep 1000 <-------------- '停止1秒钟Open TmpFile For Input As #1
Do Until EOF(1)
.....