当前位置:文档之家› VB读取文本文件内容的函数

VB读取文本文件内容的函数

'读取文本文件内容的函数
'用法:Text1 = gettxt("c:\\temp.txt")
Public Function gettxt(ByVal filename As String) As String
Dim wjh As Long, xx As String 'wjh为文件号,xx读取文件内容
wjh = FreeFile '取未使用的一个文件号
Open filename For Binary As #wjh '以 Binary 方式打开文件
xx = StrConv(InputB(LOF(wjh), #wjh), vbUnicode) '读取整个文件内容(LOF(wjh)=文件长度)
Close #wjh '关闭文件
gettxt = xx '返回文件内容
End Function


相关主题
文本预览
相关文档 最新文档