Load Web Browser HTML Source in Notepad

In this article, we will create a program that can load the HTML source code of a website into the notepad. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one Button named Button1 and labeled it as "Save HTML source in Notepad". Insert a WebBrowser, named it WebBrowser1 and in its URL property input "http://www.sourcecodester.com" You must design your interface like this: design 3. Now put this code in your code module.
  1. Imports System.IO
  2. Public Class Form1
  4. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  5. Dim source As [String] = ("source.txt")
  6. Dim writer As StreamWriter = File.CreateText(source)
  7. writer.Write(WebBrowser1.DocumentText)
  8. writer.Close()
  9. Process.Start("notepad.exe", source)
  11. End Sub
  13. End Class


We have first imported the System.IO because this supports input and output for notepad, including the ability to read and write data to streams either synchronously or asynchronously. In our button1, we have initialized first variable source as a string in which it will hold a value of source.txt. When you are going to make an extension file as string, put first "[]" to the datatype. Source.txt is the name of our text file when we put and load the html source code of our web browser. Then we have created a variable writer as StreamWriter to write or create a text file that will be named as Source.txt. Then the writer variable will write the DocumentText of the WebBrowser. This gets the HTML contents of the page displayed in the WebBrowser control to be passed through the notepad named Source.txt as the process started.


outputoutput Download the source code below and try it! :) For more inquiries just contact my number or e-mail below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz


Submitted bygiraffe (not verified)on Wed, 02/21/2024 - 17:30

its good

Add new comment