如何跳过"打开文件对话框",直接显示文本文件内容?谢谢指点!
我想在一个picture控件中显示一个文本文件的内容,用到"通用对话框",我想在程序运行时直接在picture中显示出指定文本文件的内容(比如"帮助文件.txt"),从而跳过"通用对话框"的提示窗口,但不知道如何实现这个跳过功能"通用对话框"的功能,另外如何指定呢?恳请大家指点!
我的代码如下:
Private Sub Form_Load()
Dim fso As New FileSystemObject, fil As File, ts As TextStream
Dim str As String
With CommonDialog1
.Filter = "Text Files|*.txt"
.FileName = "帮助文件.txt"
.InitDir = App.Path
.ShowOpen '如何跳过这个打开对话框???
End With
Set fil = fso.GetFile(CommonDialog1.FileName)
Set ts = fil.OpenAsTextStream(ForReading)
str = ts.ReadAll
ts.Close
End Sub