Open TxtPath.Text For Input As #F1
    i = 1
    Do While Not EOF(F1)
        Line Input #F1, INPUTVAR1
        If Trim(StrMid(INPUTVAR1, 1, 7)) <> "VERSION" Then
        Else
            Open "c:\error_pb.txt" For Output As #1
                Print #1, INPUTVAR1;
            Next i
            Close #1
        End If
        
        i = i + 1
        Me.Label1.Caption = i
    Loop
    Close #F1当我运行到            Open "c:\error_pb.txt" For Output As #1 的时候
总是提示我文件已经打开

解决方案 »

  1.   

    换一个文件号    Open TxtPath.Text For Input As #F1
        i = 1
        Do While Not EOF(F1)
            Line Input #F1, INPUTVAR1
            If Trim(StrMid(INPUTVAR1, 1, 7)) <> "VERSION" Then
            Else
                F2 = freefile()
                Open "c:\error_pb.txt" For Output As #F2
                    Print #F2, INPUTVAR1;
                Next i
                Close #F2
            End If
            
            i = i + 1
            Me.Label1.Caption = i
        Loop
        Close #F1
      

  2.   

    文件是可以同时操作N个的
    如:
    Open "C:\text1.txt" For Binary #1
    Open "C:\text2.txt" For Binary #2
    Open "C:'text3.txt" For Binary #3
    Open "C:'text4.txt" For Binary #4
    Open "C:'text5.txt" For Binary #5
    ...Get #1,1,data1
    Put #2,1,data1
    Put #3,1,data1
    Put #4,1,data1
    Put #5,1,data1
    ...Close #1
    Close #2
    Close #3
    Close #4
    Close #5
    ...
      

  3.   

    每次打开新文件前用新的文件号,这样肯定不会错啦
    生成文件号用: freefile()
    完毕后关闭文件.
      

  4.   

    说到细的只有32767个文件,因为Integer不是正整数,有负数的。
    文件号又不能有负数,所以只有32767个文件。
      

  5.   

    [from MSDN]文件号
    在 Open 语句中用来打开文件的号码。对不能访问其它应用程序的文件,使用1–255 范围内的文件号,对可由其它应用程序访问的文件,使用256–511 范围内的文件号
      

  6.   

    zyl910(910:分儿,我又来了!) 的是正解啦
      

  7.   

    可以使用FreeFile这样就可以打开