我想在点击按钮后,将123.txt文本中的回车符全部删除,代码如下:Private Sub command1_click()Open "c:\123.txt" For Input As #1
 Dim str1 As String
 
      While Not EOF(1)
            Line Input #1, str1
            str1 = Replace(str1, vbCrLf, "")
  Wend
  Close #1End Sub但是按了后,怎么没反应呢

解决方案 »

  1.   

    Open "c:\123.txt" For Input As #1 
    Open "c:\tmp.txt" For Output As #2
    Dim str1 As String 
      While Not EOF(1) 
          Line Input #1, str1 
          Print #2, str1;
      Wend 
    Close #2 
    Close #1
    Kill "c:\123.txt"
    Name "c:\tmp.txt" As "c:\123.txt"
      

  2.   

    不就多个;么?
    试试textstream 在fso里。
      

  3.   

    帮你改好了
    Private Sub Command1_Click()
    Open "c:\123.txt" For Input As #1
    Dim str1 As String
      While Not EOF(1)
          Line Input #1, str1
         s = s & str1
      Wend
      Close #1
      str1 = Replace(s, vbCrLf, "")
    Open "c:\123.txt" For Output As #1
    Print #1, s
    Close #1End Sub
      

  4.   

     str1 = Replace(s, vbCrLf, "")应为s= Replace(s, vbCrLf, "")
    其实,这句不要也行。
      

  5.   

    楼主,你的代码修改的只是字符串str1本身,而不文件内容,当然看不出文本内容的变化,明白?
      

  6.   

    一句就可以完成
    直接把整个文件读了保存为字符串然后在Replace不就可以了    'Dim bytBuffer() As Byte
        Dim strTmp As String
        Dim Length As Long
        
        Open "c:\boot.ini" For Binary As #1
        Length = LOF(1)
        'ReDim bytBuffer(Length - 1)
        strTmp = String(Length, 0)
        'Get #1, , bytBuffer
        Get #1, , strTmp
        Close #1
        strTmp = Replace(strTmp, vbCrLf, "")
        Debug.Print strTmp
        'Debug.Print Replace(StrConv(bytBuffer, vbUnicode), vbCrLf, "")
      

  7.   

    1楼和4楼大哥的代码都能成功7楼大哥你的代码会不会对小弟的系统赞成影响啊,我第一次用你的代码时,没注意没去改你的路径"c:\boot.ini",而这是不是系统文件啊,你的代码对这文件有没有影响啊