Share via


Implementing with Visual Basic

If you use Microsoft Visual Basic to implement your component, you will create an ActiveX DLL file. An ActiveX DLL is a COM component that exposes its methods to clients through Automation. The Visual Basic 6.0 New Project window provides a tool to assist you in creating the basic framework for an ActiveX DLL.

COM components use Automation to present an easy way of creating object instances. Components that use Automation are known as Automation servers. Clients of Automation servers are known as Automation controllers. When an ASP script creates an instance of an object from your component, it is acting as an Automation controller.

To access the built-in objects from a component you build in Visual Basic, you must first provide a reference in the project to the Microsoft Active Server Pages Object Library and the Component Services Type Library. You can do this by selecting the References command from the Project menu and clicking the boxes for the appropriate type libraries (Microsoft Active Server Pages Object Library, and Component Services Type Library). After you have set these two references, you can create an instance of the COM+ ObjectContext object in a function and use this object to obtain a reference to the built-in objects you wish to use. The following code snippet demonstrates obtaining a reference to the Response object.

  Public Function GetResponse()
  Dim objContext As ObjectContext
  Set objContext = GetObjectContext ()
  objContext("Response").Write ("Hello World")
End Function

note Note If you are implementing with Visual Basic, you should make sure that your component supports the Apartment threading model, as this will improve the performance of your application. You select the Apartment threading model in the Threading Model section on the General tab of the Project Properties pages.