The web Browser

 

In order to create the web browser, you have to press Ctrl+T to open up the components window and select Microsoft Internet Control. After you have selected the control, you will see the control appear in the toolbox as a small globe. To insert the Microsoft Internet Control into the form, just drag the globe into the form and a white rectangle will appears in the form. You can resize this control as you wish. This control is given the default name WebBrowser1.

The method navigate is to go the website specified by its Uniform Resource Locator(URL). The syntax is WebBrowser1.Navigate (^URL ̄). In this program, I want to load the www.vbtutor.net web page at start-up, so I type in its URL.

 The Interface

 

The Codes

Private Sub Form_Load()

WebBrowser1.Navigate ("http://www.vbtutor.net")

End Sub

 

In order to show the URL in the combo box and also to display the page title at the form caption after the page is completely downloaded, I use the following statements:

Private Sub WebBrowser1_DocumentComplete (ByVal pDisp As Object, URL As Variant)

Combo1.Text = URL

Form1.Caption = WebBrowser1.LocationName

Combo1.AddItem URL

End Sub

The following procedure will tell the user to wait while the page is loading.

Private Sub WebBrowser1_DownloadBegin ()

Combo1.Text = "Page loading, please wait"

End Sub

 

[Back to VBToday]