代码如下: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的错误,我在文件中可能找到这处文件
   这是什么原因,请高手指点

解决方案 »

  1.   

    ip.txt和你的app.exe在同一文件夹吗?
      

  2.   

    ip.txt和你的app.exe在同一文件夹吗?
    如果不在,要保证他们是在同一文件夹下
      

  3.   

    我查IP。TXT在同一个文件夹下
      

  4.   

    而且我在刚写这段代码时是OK的,今天再测试就不行了,我的电脑重起了N扁,依然如此,烦!
      

  5.   

    'shell命令还没有执行完,你就open了
    '而单步执行的时候,有时间停留,所以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)
       .....