我有这个代码。有时它会在网页中找到该单词,有时则不会。我不确定问题是什么。输入richtextbox2.text的单词也只能找到第一个单词,所以如果我把第一个单词作为“Cookies”然后放在那个“Milk”下面,它只会查找“Cookies”。有没有办法让它查找richtextbox中的所有单词?
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If WebBrowser1.DocumentText.ToLower.Contains(RichTextBox2.Text.ToLower) Then
MsgBox("its there")
Else
MsgBox("NOT THERE")
End If
End Sub
答案 0 :(得分:0)
当RichTextBox中有多个单词时,它会同时搜索这两个单词,因为它们都在RichTextBox2.Text中。您可以一次在RichTextBox中搜索每个单词或短语,如果它们位于不同的行中,如下所示:
for each s in RichTextBox2.lines
If WebBrowser1.DocumentText.ToLower.Contains(s.ToLower) Then
MsgBox(s & " is there")
Else
MsgBox(s & " IS NOT THERE")
End If
next s