问一个VB的小问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:57:48
有没有直接打开文本文档并显示出来的函数?
open函数好象不可以直接打开文挡读取内容.

文本文档通用读写函数

Public Function openfile(ByVal filepath As String) As String
Dim s As String
Open filepath For Input As #1
While Not EOF(1)
Line Input #1, sline
s = s & sline & vbCrLf
Wend
Close #1
openfile = s
End Function

Public Function savefile(ByVal filepath As String, ByVal txt As String)
Open filepath For Output As #1
Print #1, txt
Close #1
End Function

===============================
有其它需求请补充

楼上的正解.
当然,你也可以用RichTextBox控件..
那是傻瓜式的,一指定路径就显示文件啦..
什么都不用操心.呵呵..

需要自己编写,没有现成内部函数的。