Share via


Visual Basic Concepts

Running and Debugging the ActXDoc Project

In order to view the FirstDoc document, you must first run the ActXDoc project, then run another container application in which to view the FirstDoc document. In this procedure, you will run Internet Explorer (included with Visual Basic), and navigate to a .vbd file to open the ActiveX document (a .vbd file is automatically generated for every ActiveX document in a project whenever the project is run).

Note   This topic is part of a series that walks you through creating a sample ActiveX document. It begins with the topic Creating an ActiveX Document.

To view the FirstDoc ActiveX document

  1. Run the project by pressing F5.

    The project is now running. If you use Windows Explorer to view the directory where Visual Basic resides, you will find a FirstDoc.vbd file.

  2. If this is the first time you've run the project, the Project Properties dialog box will appear. Click Start Browser with URL, and type the path of the FirstDoc.vbd file, which should be in the directory where you installed Visual Basic. Internet Explorer will open and display your ActiveX document.

  3. Note in the text box that the default URL is https://www.microsoft.com. You can replace this URL with another of your choice.

  4. Click the Navigate To button. The Web page at the URL in the text box will appear in the browser.

Debugging the FirstDoc ActiveX Document

Debugging an ActiveX document is similar to debugging other ActiveX components. You can use all the tools available in Visual Basic — setting breakpoints, watching variables, using debug statements, and so on.

It's also important to remember that the container hosting the ActiveX document is its client — using objects the ActiveX document provides. While the host container is accessing the ActiveX document, stopping the project will cause an error in the host container. To avoid this, at the end of each of these procedures you will quit Internet Explorer to release the reference.

For More Information   For alternatives that cause Internet Explorer to release your ActiveX document, see "Debugging ActiveX Documents" in "Building ActiveX Documents."

Putting Your Project Into Break Mode

If you are running a project and are viewing it in Internet Explorer, you can put it into break mode (by pressing CTRL+BREAK) without causing any errors in the host application. However, be aware that modifying any code that causes Visual Basic to reset the project should be avoided.

To add a Stop statement to an ActiveX document

  1. In Internet Explorer, click the Back button to return to the FirstDoc ActiveX document.

  2. Press ALT+TAB to switch back to Visual Basic.

  3. Press CTRL+BREAK to pause the program.

  4. In the Code window, find the Click event for the cmdNavigateTo button, and place a Stop statement before the existing line of code, as shown:

    Private Sub cmdNavigateTo_Click()
       Stop ' <--- Add this to the procedure.
       Hyperlink.NavigateTo txtURL.Text
    End Sub
    
  5. Press F5 to continue.

  6. Press ALT+TAB to return to Internet Explorer.

  7. Click Navigate To. Visual Basic will return to the front of your desktop with the Code window visible, and the Stop statement highlighted.

  8. Press F5 to continue. Note that the Web page has been revisited.

Step by Step

This topic is part of a series that walks you through creating a sample ActiveX document.

To See
Go to the next step Adding a Second ActiveX Document to the ActXDoc Project
Start from the beginning Creating an ActiveX Document