VB6.0用掲示板の過去のログ(No.1)−VBレスキュー(花ちゃん)
[記事リスト] [新規投稿] [新着記事] [ワード検索] [過去ログ] [管理用]

投稿日: 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 訂正


- 関連一覧ツリー (★ をクリックするとツリー全体を一括表示します)

- 返信フォーム (この記事に返信する場合は下記フォームから投稿して下さい)

- Web Forum -