'''
e.Form.Controls("TextBox3").text = "" '清空
e.Form.Controls("Label2").text = ""
If e.Form.Controls("TextBox2").text = "" OrElse e.Form.Controls("TextBox1").text = "" Then
msgbox("请录入需检索信息!")
Return
Else
Dim app As New MSWord.Application
e.Form.Controls("Label2").text = "正在检索中......"
Dim st As Date = Date.Now '开始计时
try
Dim s As String = ""
Dim lst As new List(of String)
Dim doc = app.Documents.Open(e.Form.Controls("TextBox1").text)
Dim gjzs As String = e.Form.Controls("TextBox2").text
Dim flag As Boolean = False
Dim arr() As String = gjzs.split("、")
For Each gjz As String In arr
app.ActiveWindow.Selection.WholeStory
With app.ActiveWindow.Selection.Find
If .HitHighlight(gjz, RGB(255, 255, 0), , , , , , , True) '高亮显示找到的关键字
lst.Add(gjz)
End If
End With
If app.ActiveWindow.Selection.Find.Execute Then flag = True
If flag = False Then
e.Form.Controls("TextBox3").text = "没有找到!"
Doc.close
End If
Next
For Each gjz As String In arr
If lst.Contains(gjz) = False
s = s & gjz & "、"
End If
Next
e.Form.Controls("TextBox3").text = "找到包含的关键字有" & lst.Count & "个,如下:" & String.Join("、",lst.ToArray) & vbcrlf & "未找到包含的关键字有" & s.Split("、").Length & "个,如下:" & s
If e.Form.Controls("CheckBox1").Checked = True Then '是否打开word文档
app.Visible = True
Else
app.Visible = False
app.quit
End If
catch ex As exception
msgbox(ex.message)
app.Quit
finally
End try
e.Form.Controls("Label2").text = "检索完毕!" & "耗时: " & (Date.Now - st).TotalSeconds & "秒"
End If