程序运行后用 Open openfilename For Input As #1
打开一个txt的文件可以,但是不退出程序,再打开txt文件就不行了。

解决方案 »

  1.   

    Open openfilename For Input As #1
    没有关闭文件
    再加上
    Close #1
    试试看,行不行
      

  2.   

    Open openfilename For Input As #1
    Close #1
      

  3.   

    也就是说,每当你打开文件的时候,在你不再使用的时候就用
    Close #FileNum 关闭他
      

  4.   

    Open openfilename For Input As #1
        .
        .
        .
    Close #1
      

  5.   

    以打开的文件,要先关闭才能再打开如打开了#1号文件就要用close #1关闭
      

  6.   

    因为你没有close #1
    同理,打开某个文件就应该用完之后关掉它
      

  7.   

    Open openfilename For Input As #1
     
         Line Input #1, linestr
                Text1.Text = linestr
          Close #1
      

  8.   

    帮我看看=各个朋友!Private Sub Command1_Click()
    For i = 1 To 115
    Open "C:\1.txt" For Output As #1
        Print #1, listlinks.list(i)
    Next
    Close #1End Sub为什么我不能把listlinks 列表里list 输出到 文本谁帮个忙。谢谢
      

  9.   

    Private Sub Command1_Click()
    Open "C:\1.txt" For Output As #1For i = 1 To 115
        Print #1, listlinks.list(i)
    Next
    Close #1End Sub
      

  10.   

    不要瞎说,不Close 的文件仍然可以读写!
    除非 open ... for input Lock Read Write As #...
      

  11.   

    For i = 1 To 115
    Open "C:\1.txt" For Output As #1
        Print #1, listlinks.list(i)
    Next
    Close #1
    这段程序进行的操作和你想要实现的目标不匹配
    这个文本文件最后只能写一个数据,每次都被更新了
    如果将 关键字 Output改成 append 就可以实现了
    如下:Open "C:\1.txt" For Append As #1
    文件被关闭了,然后再打开应该是没有什么错误会发生的,除非你在程序运行之前已经
    在windows下将文本文件打开了。
      

  12.   

    找到办法了!把for 循环放到open 下面就可以了!是我自己的问题!
    :-))
      

  13.   

    Dim flag As Boolean
    Dim iDoc As IHTMLDocument2
    Dim el As Object
    Dim total As String
    Dim fso As New FileSystemObject
    Dim sTxt As TextStream
    Private Const conSwNormal = 1
    Private Sub Command1_Click()
    Command2.Enabled = False
    Text1.Text = Replace(Text1.Text, " ", "%20")
    flag = False
    Dim urllist As String
    urllist = "http://www1.baidu.com/baidu?word=intitle:" & Text1.Text & "&cl=3"
    web.Navigate urllist
    Do While Not flag
        DoEvents
        DoEvents
        DoEvents
        DoEvents
    Loop
    getList
    Launch
    End Sub
    Private Sub getList()
    Dim obj As IHTMLElement
    Dim oo As Object
    Dim tbl As HTMLBodySet iDoc = web.DocumentSet oo = iDoc.All.tags("FONT")For scan = 0 To oo.length - 1
        If InStr(oo.Item(scan).innerText, "href") > 0 Then
            posA = oo.Item(scan).sourceIndex
            Exit For
        End If
    NextFor g = posA To iDoc.All.length - 1
        If iDoc.All.Item(g).tagName = "BODY" Then
        posB = iDoc.All.Item(g).sourceIndex
        Exit For
        End If
    NextSet oo = iDoc.All.tags("BODY")For g = 0 To oo.length - 1
        If oo.Item(g).sourceIndex = posB Then
              Set tbl = oo.Item(g)
            Exit For
        End If
    NextFor l = 0 To tbl.All.length - 1
        If tbl.All.Item(l).tagName = "A" Then
            Set el = tbl.All.Item(l)
            strcontent = strcontent & "<a href='" & el.href & "'>" & el.innerText & "</a><br>" & vbCrLf
        End If
    Next
    Set sTxt = fso.CreateTextFile(App.Path & "\jobResult.htm")
    header = "<html><head></head><body>" & vbCrLf
    total = header & strcontent & "</body></html>"
    sTxt.write header & strcontent & "</body></html>"
    sTxt.Close
    Set fso = NothingEnd SubPrivate Sub Launch()
    web.Document.write (total & "<br>Ce fichier est disponible sous le nom jobResult.htm dans le r閜ertoire de l'application")
    Command2.Enabled = True
    End SubPrivate Sub Command2_Click()
    web.Navigate App.Path & "\jobResult.htm"End SubPrivate Sub Form_Resize()
    web.Width = Me.Width - 151
    If (Me.Width - 151 - Command2.Width - 10 > 0) Then Command2.Left = Me.Width - 151 - Command2.Width - 10
    If Me.Width - 3500 > 0 Then Text1.Width = Me.Width - 3500
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Command1_Click
    End SubPrivate Sub web_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    flag = True
    End Sub
    哪个朋友帮忙看看这个代码-返回的是整理后的搜索结果!可我想把不要的祛除!而且能不断的继续下面的页码!谢谢