您的位置:首页 > 其它

使用ADODB.Stream对象读文本文件

2007-04-19 14:16 411 查看



Function ReadTextFile()Function ReadTextFile(FileName, CharSet)


Const adTypeText = 2




'Create Stream object


Dim BinaryStream


Set BinaryStream = CreateObject("ADODB.Stream")




'Specify stream type - we want To get binary data.


BinaryStream.Type = adTypeText




'Specify charset For the source text (unicode) data.


If Len(CharSet) > 0 Then


BinaryStream.CharSet = CharSet


End If




'Open the stream


BinaryStream.Open




'Load the file data from disk To stream object


BinaryStream.LoadFromFile FileName




'Open the stream And get binary data from the object


ReadTextFile = BinaryStream.ReadText


End Function



 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  function