文本文件导入-太阳雨
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


文本文件导入

发表时间:2011/3/22 评论(1) 浏览(7763)  评论 | 加入收藏 | 复制
   
摘 要:vba代码
正 文:
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

Access软件网交流QQ群(群号:198465573)
 
 相关文章
[access查询]将access表导出为TXT文件及将TXT文件...  【Big Young  2012/6/26】
[access查询]将access表导出为EXCEL表及将EXCE...  【Big Young  2012/6/27】
【access源码示例】-word导入导出系列-替换方式导出  【金宇  2012/8/6】
【Access源码示例】-导入导出系列-根据SQL语句导出数据到t...  【金宇  2012/8/20】
常见问答
技术分类
相关资源
文章搜索
关于作者

太阳雨

文章分类

文章存档

友情链接