# 嗯，有点烦

Posted by 小吴 on September 02, 1998 at 08:00:54:

In Reply to: 将资料以固定格式写入档案中 posted by Chih_Ming Liu on September 01, 1998 at 08:57:34:

由于 vb6 开始使用 Unicode，因此如果你要写出固定格式的文件时便有点麻烦。以下是一个例子

Dim strRecord As String
Dim byeBuffer() As Byte

Open "C:\test" For Binary As #1

strRecord = StrConv(Space$(62), vbFromUnicode)
MidB$(strRecord, 1, 20) = StrConv("姓名", vbFromUnicode)
MidB$(strRecord, 21, 40) = StrConv("地址", vbFromUnicode)
MidB$(strRecord, 61, 2) = StrConv(vbCrlf, vbFromUnicode) ' 换列

bytBuffer = strRecord

Put #1, , bytBuffer
...

Follow Ups: