Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGet all text or the selected text from a WebBrowser control by using the control's methods
DescriptionThis example shows how to get all text or the selected text from a WebBrowser control by using the control's methods in Visual Basic 6.
KeywordsWebBrowser, browser, internet, text, selected text
CategoriesTips and Tricks, Controls
 
Thanks to James Hansen.

The program uses the WebBrowser control's Document object represents the Web page loaded. That object's Body property refers to the entire Web page. The ActiveElement property refers to the selected text. The program uses those objects' InnerText, OuterText, InnerHtml, and OuterHtml properties to learn about the Web page's text and the selected text.

 
' Grab text from the WebBrowser control.
Private Sub Command1_Click()
    txtResult(1).Text = WebBrowser1.Document.Body.InnerText
    txtResult(2).Text = WebBrowser1.Document.Body.OuterText
    txtResult(3).Text = WebBrowser1.Document.Body.InnerHtml
    txtResult(4).Text = WebBrowser1.Document.Body.OuterHtml
    txtResult(5).Text = _
        WebBrowser1.Document.ActiveElement.InnerText
    txtResult(6).Text = _
        WebBrowser1.Document.ActiveElement.OuterText
    txtResult(7).Text = _
        WebBrowser1.Document.ActiveElement.InnerHtml
    txtResult(8).Text = _
        WebBrowser1.Document.ActiveElement.OuterHtml
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated