Basically everyone navigates the Internet using commercially produced web browsers such the Internet Explorer produced by Microsoft or those open source browsers designed by the experts such FireFox , Opera and the latest Chrome created by Google. However, isn't it cool that if we can create our very own web browser that we can customize to our own taste ? Yes, you can do that in VB2008, and pretty easy too. In this chapter, we shall show you how to create a simple web browser and get it running in a few minutes.
First of all, start a new project in VB2008 and name it with any name you like. Here I am just using the name webbrowser. Change the name of Form1 to webbrowser and the text property to My First Web Browser and set its size property to 640,480. Next, you need to add an engine so that your web browser can connect to the Internet, and this very engine is the WebBrowser control, located on the Toolbox on the left side, set the size property to 600,400. Next, drag a text box and place it at the top of the WebBrowser control, this will be the address bar where the user can enter the URL. Lastly, place a command button beside the text box and label it as Go. The design interface is shown below:
The code for the web browser is surprisingly simple, it is only a single line code! Double click on the Go button and key in the following code:
Public
Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickmyWebBrowser.Navigate(TextBox1.Text)
End SubEnd
Class¡¡
Now run the the program , type in any URL and click the Go button. You will be able to browse any web page you want.
Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy