Article ID: 168428 - View products that this article applies to.
This article was previously published under Q168428
Visual Basic 5.0 introduces the ability to create ActiveX documents (.VBD files) for use with Internet browsers. This article will walk you step-by-step through creating a simple ActiveX document, show you how to test it while within the Visual Basic 5.0 development environment, then test it outside of the Visual Basic 5.0 development environment.
The power of the Internet is that potential users from all of the world will be able to hit and view your page. (The same applies to the Intranet, although on a smaller scale; users all over your corporation may be able to hit and view your web page). With this in mind, different users will have different configurations and different software installed on their PC's. When your ActiveX page is hit by an Internet user, Internet Explorer searches the local PC for all of the files required by the document. If a required file is present and has a version equal to or greater than the version you require, it uses it. If a file is missing or is older than the version required, Internet Explorer prompts the user to install the file and will proceed to do so.
While testing an ActiveX document, a problem occurs for developers because all of the required files are already installed onto the development machine. So how do you simulate a client's machine, one which has not been exposed to Visual Basic and the components you are using or which you've created? This article will also describe how to simulate such an environment.
To begin, you need to create a simple ActiveX document for testing purposes. If you already have an ActiveX document to test, proceed to the section "Testing Your Document Using Visual Basic 5.0" later in this article.
Creating a Simple ActiveX Document
Testing Your Document Using Visual Basic 5.0The following steps assume you have Microsoft Internet Explorer version 3.00 or later installed onto your system. To obtain the latest version of Internet Explorer be sure to visit the following Web site:
Creating Your Internet Download SetupThe following steps take you through the creation of your Internet download setup. If you have created your own ActiveX document (rather that using the example created above), substitute your ActiveX document name where necessary.
Testing the Internet DownloadAs a developer, you may want to test the Internet Download from your own machine first. Remember, however, that because Visual Basic 5 is already installed on your machine, you know all of the necessary files are installed and the ActiveX document should load without incident. To test the document from the development machine, locate the Internet download files the Setup Wizard created. In the setup folder there will be an HTM file; if you created the example above this file will be named MyActiveXDocument.HTM. Simply double-click the file or locate it with Internet Explorer to open it.
The second test you should apply to your ActiveX document is testing it from a machine without Visual Basic 5.0 installed. If you do not have such a machine available to you for testing, refer to the "Simulating a Clean Machine" section of this article.
From a machine that does not have Visual Basic 5.0 installed, use Internet Explorer to locate and open the HTM file created by the Setup Wizard.
IMPORTANT NOTE: Before testing the ActiveX document, be sure the safety level in Internet Explorer is set to Medium or None. If the safety level is set to High, the required files will not get downloaded and the ActiveX document will not load. To check the security level in Internet Explorer, choose Options from the View menu. From the Options window, select the Security tab, and then click the Safety Level button.
If you set the Safety Level to None, all of the missing components will be installed without warning. If the Safety Level is set to Medium, the following warnings will occur:
First, you will be warned that an attempt to install the CAB file is being made if you created the example above you will be prompted to install MyActiveDocument.CAB. If you respond Yes, the MyActiveXDocument.Exe and MyActiveXDocument.INF will be installed onto the client machine in the Windows\OCCache folder.
Second, you will be asked if you wish to install Microsoft Automation. The Authenticode screen will display information about this component. If you respond Yes, a similar screen will warn you that the Microsoft Visual Basic 5.0 Run-time Library is going to be installed. Both of these components will be installed from the Microsoft Web site into the Windows\System folder (Windows\System32 folder on Windows NT).
Third, a script warning will appear warning the user that the HTM file contains scripting code. This code is necessary in order to view your ActiveX document.
These warnings are all part of the Internet Explorer's safety mechanisms. If you do not receive all of the above warnings, do not be alarmed. You may not receive a warning if a necessary component is already installed on the client machine or a security level option in Internet Explorer is set to something other than the defaults.
As part of testing, you may wish to test various Internet Explorer security settings to be sure your document loads as expected under varying circumstances.
Simulating a Clean MachineAs a developer, you should test your application on various machines with varying configurations. However, if you do not have a "clean machine" (one that does not have Visual Basic 5.0 or the Visual Basic 5.0 Run-time Library installed), the steps outlined below describe how to configure a development machine so that it behaves like a clean client. These steps may also be taken to clean a client machine that may have been previously exposed to your ActiveX document, Visual Basic 5.0, or the Visual Basic 5.0 Run-time Library.
WARNING: Before following the steps below to simulate a clean machine, be aware that unregistering, renaming, and deleting any of the following files could impact other applications installed onto your machine. For more information about undoing the steps provided here, see the "Restoring Your Machine" section of this article.
In order to clean a machine for testing an Internet download, you must begin by unregistering the Visual Basic 5.0 Run-time Library. This step will require a copy of REGSVR32.EXE. This file may be installed onto your development machine; if it is not, it may be found on the Visual Basic 5.0 installation CD-ROM.
Restoring Your MachineOpening the HTM file as described in the last step of the previous section of this article will restore your machine to its original configuration. Internet Explorer will download and register each required file for you. However, if something should go wrong during the Internet download setup, you can reverse the changes made by restoring all of the original files and registering the necessary components.
Any file deleted or renamed would need to be renamed back to its original name or restored from the Windows Recycle Bin. If a file cannot be restored from the Windows Recycle Bin, an original may be found on the Visual Basic 5.0 CD-ROM (unless the file was provided by a third party, in which case you will need to restore the file from the appropriate location). Once the necessary files have been restored, you can run REGSVR32.EXE to register those files that were initially unregistered. For example, to register the Visual Basic 5.0 Run-time Library, execute the following command from the run dialog:
REGSVR32 <Path to Windows>\System\MSVBVM32.DLL
TroubleshootingThis section addresses some of the problems you might encounter during the Internet Download setup.
You receive one of the following error messages when you try to delete or rename the Visual Basic 5.0 Run-time Library:
Cannot delete MSVBVM50.DLL: Access is denied.
Cannot rename MSVBVM50.DLL: Access is denied.
You cannot delete a file while it is in use because Visual Basic 5.0 uses this file while it is running. Be sure Visual Basic 5.0 is not running when you attempt to delete this file. This error may also occur if Internet Explorer is currently or has recently viewed a Visual Basic 5.0 ActiveX Document. In this case, close Internet Explorer before attempting to delete the file.
You receive the following error message:
The dynamic link library could not be found in the specified path...
The ActiveX document file is still present on the machine. Delete or rename the ActiveX document file found in the Windows\OCCache folder and refresh the page. If you built the ActiveX document example in this article, the file would be named MyActiveXDocument.Exe.
You receive the following error message:
An error has occurred copying MSVBVM50.DLL. Ensure the location
specified below is correct...C:\TEMP\ICD10E.TMP
The exact file names and paths may vary.
There is insufficient disk space on the target machine. Free up some disk space on the target machine and refresh the page.
A dialog box with the following messages appear in Internet Explorer:
Opening file <ActiveX Document>.VBD
What would you like to do with this file?
Open it or Save it to disk.
This error occurs because the Visual Basic 5.0 Run-time Library (MSVBVM50.DLL) is not installed. This will most likely occur if the Internet Explorer safety level is set to High. Set the Internet Explorer safety level to Medium or None.
Visual Basic 5.0 Component Tools Guide, Chapter 5 "Creating an ActiveX Document"
Visual Basic 5.0 Programmer's Guide, Chapter 17 "Distributing Your Applications"
For more information, see the following Webcast:
How Does Internet Component Download Work?
Article ID: 168428 - Last Review: July 13, 2004 - Revision: 2.1