设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

格式化读取文本文件

1970-1-1 08:00| 发布者: harsonliao| 查看: 2310| 评论: 0

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

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-30 10:28 , Processed in 0.079880 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部