有保留之前請你試驗的 KaLaOK 源碼嗎?
裡面
FileNo = FreeFile
Open SaveFileNameTextBox.Tag + SaveFileNameTextBox.Text For Binary Access Write As FileNo
If LOF(FileNo) = 0 Then
ReDim BufferStr(1)
BufferStr(0) = &HFF 'FF FE 是UniCode的識別檔頭
BufferStr(1) = &HFE
Put #FileNo, , BufferStr
End If
String2ByteArray strFileMeat, BufferStr ' 這裡是字串轉byte
Seek #FileNo, 3
Put #FileNo, , BufferStr
Close FileNo
================================
Public Function ByteArray2String(ByteArray() As Byte, OutputString As String)
Dim i As Long
OutputString = ""
For i = 0 To UBound(ByteArray)
If ByteArray(i) = 0 Then Exit For
OutputString = OutputString & ChrB(ByteArray(i))
Next i
OutputString = StrConv(OutputString, vbUnicode)
End Function
Public Function String2ByteArray(OutputString, ByteArray() As Byte)
Dim i, j As Long
Dim TempStr As String
ReDim ByteArray(1 To Len(OutputString) * 2)
For i = 1 To Len(OutputString) * 2
j = j + 1
ByteArray(j) = AscB(MidB(OutputString, i, 1))
Next i
End Function