>
VB2019 VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Code 中文VB About Us

Lesson 19 : Creating a Web Browser


In this Lesson, we will show you how to create a simple web browser and get it running in a few minutes.

First, start a new project in Visual Basic 2010 and name it with any name you like. Here we use the name Web Browser. Change the name of Form1 to MyWebBrowser and the text property to 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. This engine is the WebBrowser control, located on the Toolbox on the left side. Set its size property to 600,400. Next, drag a text box and place it at the top of the WebBrowser control, this serves as the address bar where the user can enter the URL. Lastly, place a command button beside the text box and label it as Go and change its name to Go as well.

The design interface is shown in Figure 19.1

Visual Basic 2010
Figure 19.1

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 Go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 MyWebBrowser.Navigate(TextBox1.Text)
End Sub

End Class

Now run the program , type in any URL and click the Go button. You will be able to browse any web page you want.

Visual Basic 2010

Figure 19.2: The Runtime Interface


❮ Previous Lesson Next Lesson ❯


Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy