Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search HTMLDocument for Text

Status
Not open for further replies.

EZEason

Programmer
Dec 11, 2000
213
US
I have a HTMLDocument that works fine. What I need to do is search this document for spacific words. Like InStr(), but for a document. I can put the document in to a text box like this:
Code:
Dim Doc As HTMLDocument
Set Doc = WebBrowser1.document
Text1.Text = Doc.documentElement.innerHTML

How do I search the text for a certain words?

What doesn't kill you makes you stronger.
 
Well, the innerhtml property evaluates to a string. (Note that you can assign it to the text property of the textbox, which of course requires a string.) As such, string functions work on it. e. g.
Code:
Dim myString as string
'etc
myString = Doc.documentElement.innerHTML
msgbox instr(myString, "WordImLookingFor") <> 0
The msgbox will show true if the word is contained in the text, and false if not.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top