私はこれをテストしませんでしたが、それは正しいトラックに置くことができます。
Dim b1 As Byte
Dim i As Long
' Open file in Binary mode (since you have at least one binary field)
Open "MyFile.dat" For Binary As #1
Do
' Advance to 7th | character from here
For i = 1 To 7
Do
Get #1, , b1
If b1 = 124 Then ' If Chr(b1) = "|" is perhaps more readable
' It's a "|" pipe
Exit Do
End If
Loop
Next i
'Skip the 24-byte field
Seek #1, Seek(1) + 24
If EOF(1) Then
' We're all done
Exit Do
End If
' Record presumably ends here.
' Replace the next two bytes with the CR LF record delimiter
Put #1, , CByte(10) ' CR
Put #1, , CByte(13) ' LF
' Hopefully those were your hex FF and FE that just got overwritten.
' Should really test for this before overwriting,
' but what the heck.
Loop
Close #1
EDITはちょうどそれをテストしました。それはかなりうまくいく。ただし、テキストとして読み込む場合はDOSエンコードを仮定します。
これは、CR LFレコード区切り文字とフリーフォームテキストCR LFを区別しません。それは基本的にOPが求めているものです。 –
さらに、そこには24バイトのバイナリフィールドがあります。 'String'としてロードすることはできません! –