注意哦
1一定是txt格式的 也就是说能被记事本直接打开的
2一定是Unicode编码的
3不能引用非vb默认的库知道的大侠麻烦写一下吧
1一定是txt格式的 也就是说能被记事本直接打开的
2一定是Unicode编码的
3不能引用非vb默认的库知道的大侠麻烦写一下吧
解决方案 »
- 把文件读到内存中,然后在内存中打开这个文件
- 金蝶k3二次开发bos 单据转换
- 如何用vb6改变MDB内的文件名
- 特殊字符显示成了方框怎么解决??
- 问题错误提示:field_width(i) = rs.Fields(i).Size 无效的方法(size)。
- 程序用wise打包,安装完成后无法运行,出现"方法'~'作用于对象'~'失败",是怎么回事啊
- 难题!!!
- 一个关于access自动增量的小问题?在线等!
- vb6.0中如何查找并替换xml中的字符串
- 编一个子过程来实现在文本框里输入数据并敲回车能转到下个文本框
- 请教下,我这段代码哪里出问题了!
- 为什么在vb中chr(13)要与chr(10)同时运用才能达到换行的效果?原理是啥?
'sHTML为要写入的字符,sFilePathName为要写入的文件名及所在路径,isOverWrite判断写入的文件名是否存在
On Error GoTo Err
Dim strLastError As String
strLastError = ""
Dim iOverwrite As Integer
If isOverWrite = False Then
iOverwrite = 1
Else
iOverwrite = 2
End If
Dim stm As Object
Set stm = CreateObject("adodb.stream")
stm.Type = 2 '以本模式读取
stm.Mode = 3
stm.Charset = "Unicode"
stm.Open
stm.WriteText sHTML
'iOverwrit用来决断是否覆盖写入
stm.SaveToFile sFilePathName, iOverwrite
If Err <> 0 Then
strLastError = Err & " " & Err.Description
End If
stm.Flush
stm.Close
Set stm = Nothing
ConvertToUni = Err
Exit Function
Err:
MsgBox Err.Description & " " & Err.Number
stm.Flush
stm.Close
Set stm = Nothing
ConvertToUni = Err
End Function
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