January 17, 2021
Hot Topics:

Creating a Web Browser

  • By Karl Moore
  • Send Email »
  • More Articles »

The main commands for controlling your WebBrowser control are very simple. Let's cover them now:

Visiting a Site

To visit a site, call the Navigate method, passing a Web address. Once a site has loaded into the WebBrowser control, the surfer can use it just like Internet Explorer. Let's look at two quick samples for opening a site:

WebBrowser1.Navigate (txtWebAddress.Text)
WebBrowser1.Navigate ("http://www.vbworld.com/")

Navigating a Site

Once you're at a site, you may want to move around, going backwards and forwards. You can do that easily via the GoBack and GoForward methods, like this:


Refreshing and Stopping

If a site is taking too long to load, the user might want to stop it, then refresh. Or perhaps the surfer just needs to refresh and view the latest information. The Stop and Refresh methods of the WebBrowser control work just like Internet Explorer and can be run like this:


Searching for Home

To visit the default home page, you can run the simple GoHome method. And if you want to display the default search page, try out the GoSearch method. Here's an example:


Handling Errors

It's worth noting that a lot of WebBrowser commands are prone to silly, menial errors, so feel free to use 'On Error Resume Next' statements liberally.

Page 3 of 8

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date