7,762
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private fso As New FileSystemObject
Private 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