How To Write a Visual Basic COM Component for Use Within Active Server Pages

Article translations Article translations
Article ID: 299635 - View products that this article applies to.
This article was previously published under Q299635
Expand all | Collapse all

On This Page


This step-by-step procedure demonstrates how to write a Component Object Model (COM) component for use within Active Server Pages (ASP).

The COM Component for ASP

  1. Create a new ActiveX DLL project in Visual Basic.
  2. Name the project VBASPProject, and name the class VBASPClass.
  3. Paste the following public method into the class module:
    Public Function GetString() As String
        ' Return the string Hello World!
        GetString = "Hello World!" 
    End Function
  4. From the File menu, click Make VBASPProject.dll to compile the dynamic-link library (DLL).
  5. In Notepad, create a new ASP file, and paste the following code:
           set obj = Server.CreateObject("VBASPProject.VBASPClass")
           Response.Write obj.GetString
  6. Save this ASP file in a virtual directory that is a Microsoft Internet Information Server (IIS) Web Application.
  7. In your Web browser, run the ASP page. The text, "Hello World!", is displayed.


The preceding sample is very simplistic. For more information on building scaleable Visual Basic components for use in ASP pages, refer to the following articles:
243548 INFO: Design Guidelines for VB Components Under ASP
264957 BUG: VB DLL Has Memory Leaks and Crashes in COM+ if 'Retain In Memory' Not Set
ASP Component Guidelines

Agility in Server Components


Article ID: 299635 - Last Review: June 29, 2004 - Revision: 1.1
  • Microsoft Active Server Pages 4.0
kbhowto kbhowtomaster KB299635
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from