读取:
Dim TempFile As Long
Dim LoadBytes() As ByteTempFile=FreeFile
Open 文件名 For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)写入:
Dim TempFile As Long
Dim SaveBytes() As ByteSaveBytes=StrConv(Text1.Text,vbFromUniCode)TempFile=FreeFile
Open 文件名 For Binary As #TempFile
Put #TempFile,,SaveBytes
Close TempFile

解决方案 »

  1.   

    二进制不行,要以文本方式读出,然后
    NewTxt =Replace(txt,VBVRLF & VBVRLF,VBVRLF)
    即可
      

  2.   

    以上都不能同时满足去掉空行,和包含中文,如下代码。
    Dim strTmp As String, strTotal As String, FileName As String
        Dim objFile As Scripting.FileSystemObject, i As Integer
        If File1.FileName = "" Then
            MsgBox "请选择文件!"
            Exit Sub
        End If
        Set objFile = CreateObject("Scripting.FileSystemObject")
        FileName = File1.Path & "\" & File1.FileName
        objFile.CreateTextFile FileName & "001"
        Open FileName For Input As #1
        Open FileName & "001" For Output As #2
        Do While Not EOF(1)
            Line Input #1, strTmp
            If Trim(strTmp) <> Trim(Text1.Text) Then
                Print #2, strTmp
            End If
            i = i + 1
        Loop
        Close #1
        Close #2