写好了,代码如下:Option ExplicitPrivate fso As New FileSystemObjectPrivate Sub Command1_Click() If Combo1.Text = "" Then MsgBox "搜索内容为空!", vbCritical Exit Sub End If
Dim strPath As String strPath = fso.BuildPath(App.Path, Combo1.Text & ".txt")
If Not fso.FileExists(strPath) Then MsgBox "文件未找到!", vbCritical Exit Sub End If
Dim objStream As TextStream Set objStream = fso.OpenTextFile(strPath, ForReading, False)
Dim strContent As String strContent = objStream.ReadAll
objStream.Close
MsgBox strContent End Sub运行示例:下载地址: 链接:https://pan.baidu.com/s/1jB1vUIstev785KNzrGC41g 提取码:oq0y
课表什么格式的?doc?xls?txt?
用什么显示?打开word/excel/notepad程序?弹出对话框?
If Combo1.Text = "" Then
MsgBox "搜索内容为空!", vbCritical
Exit Sub
End If
Dim strPath As String
strPath = fso.BuildPath(App.Path, Combo1.Text & ".txt")
If Not fso.FileExists(strPath) Then
MsgBox "文件未找到!", vbCritical
Exit Sub
End If
Dim objStream As TextStream
Set objStream = fso.OpenTextFile(strPath, ForReading, False)
Dim strContent As String
strContent = objStream.ReadAll
objStream.Close
MsgBox strContent
End Sub运行示例:下载地址:
链接:https://pan.baidu.com/s/1jB1vUIstev785KNzrGC41g
提取码:oq0y