Lesson 33: Internet and Web Applications.

 Part1: The Web Browser

If you are bored with existing web browsers, you can create your very own web browser using Visual Basic. In order to create the web browser, launch Visual Basic 6, press Ctrl+T to open up the components window and then select Microsoft Internet Control. The control will 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 appear in the form. You can resize this control to the size you wish. This control is given the default name WebBrowser1
To design the interface, you need to insert one combo box which will be used to display the URLs. In addition, you need to insert a few images which will function as command buttons for the user to navigate the Internet; they are the Go command, the Back command, the Forward command, the Refresh command and the Home command. You can actually put in the command buttons instead of the images, but using images will definitely improve the look of the browser.
The code for all the commands are relatively easy to write. There are many methods, events, and properties associated with the web browser but you need to know just a few of them to come up with a functional Internet browser
The method navigate is to go the website specified by its Uniform Resource Locator(URL). The syntax is WebBrowser1.Navigate (“URL”). In this program, we want to load the www.vbtutor.net web page at start-up.



The Code
 
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, we 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

Share on Google Plus

About M

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 comments:

Post a Comment