投稿日 | : 2003/07/16(Wed) 15:41 |
投稿者 | : 花ちゃん |
Eメール | : |
URL | : |
タイトル | : Re: テキストファイルの内容を1行だけ削除したい |
スマートではありませんが、少しでも高速に処理したいなら、下記の方法でも。
Private Sub Command1_Click()
Dim DelTxt As String
Dim Fso As New FileSystemObject
Dim FsoTS As TextStream
Dim DelByt As Long
Dim FilePath As String
Dim bytArray2() As Byte
Dim bytArray() As Byte
Dim intFileNo As Integer
Dim lngFileLenB As Long
FilePath = App.Path & "\test.txt"
Set FsoTS = Fso.OpenTextFile(FilePath)
DelTxt = FsoTS.ReadLine
FsoTS.Close
Set FsoTS = Nothing
DelByt = LenB(StrConv(DelTxt, vbFromUnicode)) + 2
lngFileLenB = FileLen(FilePath)
ReDim bytArray2(DelByt - 1)
ReDim bytArray(lngFileLenB - DelByt - 1)
intFileNo = FreeFile
Open FilePath For Binary As #intFileNo
Get #intFileNo, , bytArray2
Get #intFileNo, , bytArray
Close #intFileNo
Kill FilePath
intFileNo = FreeFile
' Text1.Text = StrConv(bytArray, vbUnicode)
Open FilePath For Binary Access Write As #intFileNo
Put #intFileNo, , bytArray
Close #intFileNo
End Sub
# 2003/08/05 訂正