How to Read Source Code of Web Page in VB.Net

This tutorial is all about How to Read Source Code of Web Page in VB.Net. With this tutorial you can Read Source Code of Web Page in VB.Net easily. So let’s get started:

  • First is open the Visual Basic, Select File on the menu, then click New and create a new project.

  • Then a New Project Dialog will appear. You can rename your project, depending on what you like to name it. After that click OK

  • Design your form like this just like what I’ve shown you below.
    Add a Webrowser, Button and Textbox.

 

  • Add this code to the button.
    [vbnet]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ‘when button1 cliked, webbrowser is navigated to the page
    WebBrowser1.Navigate(“http://www.youtube.com”)End Sub

    [/vbnet]

  • When page is downloaded, page source will be displayed through DocumentCompleted Event then Add this code:
    [vbnet]
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    ‘When webbrower finish opening the page, source page is diplayed in text box
    TextBox1.Text = WebBrowser1.DocumentText
    End Sub
    [/vbnet]
  • Finally, Click F5 to run Project.
  • Output:

If you have any comments or suggestion about on How to Read Source Code of Web Page in VB.Net, Please Feel Free to contact our webpage.

Download How to Read Source Code of Web Page in VB.Net Code Here

Other articles you might read also:

 

 

Leave a Comment