
Visual Basic .NET – Simple Web Browser
Topic: Visual Basic
Screencast Included.
Learn how to create a simple web browser using Microsoft Visual Basic Express Edition 2010
Before you start making your very own web browser using visual basic you need a compiler. Please read this if you don’t have the VB .NET Express Edition. http://www.itechsociety.com/2010/09/microsoft-visual-studio-express-edition/
Starting Up
First start up your Integrated Development Environment(IDE). In this tutorial I will be using MS Visual Basic 2010 Express Edition. Create a new Project by clicking File > New Project or ctrl + N for windows.
You will then be prompted with a new form. We will transform this simple form and make a web browser change its property according to the following:
- Text – My Web Browser
If you can’t see your toolbox then in the Menu bar just click View > Other Windows > Toolbox or hit ctrl+alt+x for windows.
Go on to the toolbox and double click the WebBrowser tool. You will see that the WebBrowsertool will occupy the whole form.For us to resize the WebBrowser, we have to undock it from the parent container. Select the WebBrowser and then clicking the right arrow head on the top right part of the form will show you “undock in parent container” option. Click that.
Now click again the WebBrowser and then try to resize it according your heart’s desire using your mouse. Now change the URL property to a website that you want to visit. In this vb example I used google.com.
- Url – google.com
We can now try this one first. But before we do that make sure that you are connected to the internet. You must now be able to visit google.com.
The Codes
Let’s add a new button. We will try to navigate away from google using this button. Change it’s properties according to the following:
- Text – Go
- Name – GoBtn
Double click the button to create a trigger. You will see that a private sub will be created for you. In between the private sub and end sub type in this code.
WebBrowser1.Navigate("facebook.com")
You should now have something like this.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.Navigate("facebook.com") End Sub
You can replace this line to anything website address that you want.
"facebook.com"So if that’s perfectly navigating you away from google and bringing you to the website that you have specified, we are now ready to move one. Of course we don’t want to make a web browser that is difficult to use. We need a way to make things easier for our user to change into different websites. The solution there is the address box. The address box will serve as user input for the web address that they want to access.
The Address Bar
So to add a textbox click the textbox tool from the toolbox. Drag and drop it to our form then change the following attributes.
- Name – addressTxt
Then go back to our button and change this line
WebBrowser1.Navigate("facebook.com")
to this
WebBrowser1.Navigate(addressTxt.Text)
This simply means that we want to navigate to what ever is the text value of addressTxt.
Now try the web browser. Go to different websites like facebook, youtube, and google.
Extra Buttons
Of course we also need a way for our users to navigate back and forward from web pages. We should also add other basic buttons like refresh and stop. So let’s try to do this.
First add 4 different buttons with the following attributes.
| Button 1 | Name: BackBtn Text: Back Size: 40, 40 |
| Button 2 | Name: RefreshBtn Text: Refresh Size: 40, 40 |
| Button 3 | Name: StopBtn Text: Stop Size: 40, 40 |
| Button 4 | Name: ForwardBtn Text: Forward Size: 40, 40 |
Next. Double click the buttons to create a new trigger and add these codes.
- For BackBtn
WebBrowser1.GoBack()
- For RefreshBtn
WebBrowser1.Refresh()
- For StopBtn
WebBrowser1.Stop()
- For ForwardBtn
WebBrowser1.GoForward()
That should work perfectly now.
Final Touches
We can now fix the overall appearance of our application. You can try to add an image for the buttons. You can found lots of cool icons here at IconArchive.
To make our program follow the size of the window, apply the following anchor attributes:
| Web Browser | Anchor : Top, Bottom, Left, Right |
| Navigation Buttons | Anchor : Top, Left |
| Address Textbox | Anchor: Top, Left, Right |
| Go Button | Top, Right |
Related posts:
- How to – Change My Ip Address
- Fix Your Facebook Thumbnail
- Get a Compiler for C/C++
- HTML Tutorial 1 – Context Editor
- Alpha Test Update: How About a New Design?












Hi Keith, thank for all of these, keep goin’, God Bless….