成都减肥lbodo:vb中保存文本为Unicode编码的txt文件

来源:百度文库 编辑:中财网 时间:2024/10/05 14:02:35
 
Sub WriteUnicodeFile(ByVal FileName As String, ByVal Text As String)
Const BOM As Integer = &HFEFF
Dim hFile As Integer
Dim aBytes() As Byte

aBytes = Text

If LenB(Dir(FileName)) <> 0 Then
Kill FileName
End If

hFile = FreeFile()
Open FileName For Binary Access Write Lock Read Write As #hFile

Put #hFile, , BOM
Put #hFile, , aBytes

Close #hFile
End Sub