会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > OFFICE系统集成 > 正文

格式化读取文本文件

时间:2003-12-20 23:03 来源:第十空间 作者:harsonli… 阅读:

Function ReadtxtFile(strPathName As String) As String
On Error GoTo Exit_Err
Dim strFile As String

Open strPathName For Input As #1
ReadtxtFile = ""
strFile = ""

Do While Not EOF(1)
Line Input #1, strFile ' = Input(1, #1)
if ReadtxtFile="" then
ReadtxtFile = strFile
else
ReadtxtFile = ReadtxtFile & vbCrLf & strFile
end if
Loop
Close #1

Exit Function
Exit_Err:
MsgBox Err.Description
Exit Function
End Function


调用方法:
Private Sub 命令4_Click()
Me.txt1 = ReadtxtFile("c:\file1.txt")
End Sub

(责任编辑:admin)

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: