Tutorial-Web Home > An Overview in Creating An ActiveX COM Object Component > Section 1: Creating the Component










Site Menu

An Overview in Utilizing ASP to Provide Database Access Through Web Browsers

An Overview in CDONTS

Search the Web for other ASP Tutorials

Available ActiveX Components and Source Code

A good reference guide to ASP and COM Objects
cover
More Resources











An Overview in Creating a COM ActiveX DLL for Use with ASP Scripts
by Derrald Farnsworth-Livingston

Technical Setup Stuff

In this document we will discuss how to write functions in ActiveX Dlls and then call those same functions from ASP Scripts. Although writing dlls can be accomplished using a variety of languages we will focus on Visual Basic (version 6.0).

We shall begin by creating the DLL in Visual Basic. As an example we will create a simple function that adds two numbers together. The setup in Visual Basic is very important. When we first create the project we are asked to choose the type of program we are creating. We want to create an ActiveX DLL.

Once we choose this we are given a blank project. You will want to change the reference to this project to something a little more understandable than Project1 or Project2 or Project3, well you get the picture. From the menu choose Project and then Project1 Properties. (Although it may be Project2 properties, or Project3 properties, etc.) Under the ProjectName box enter whatever name you will wish to reference this object by. In our case we shall name it "AdditionHelper".

We now want to change the names or references on the class object. Click on the Class1 module. In the properties box, normally on the right hand side of the screen, change the (name) to something pertinant. We shall name this "Addme". We have now set up the foundation for the DLL.

Code, Code, Code

We will now begin to code the DLL. The first thing that any programmer needs to do is declare the variables. We will place the following lines into our Addme class:

Public FirstNumber As Variant
Public SecondNumber As Variant

We will now create the function that adds these two variables. We will call this function AdditionFunction. AdditionFunction will receive the two variables which it will add then pass back the result. Here is the code:

Function AdditionFunction(FirstNumber, SecondNumber)
    AdditionFunction = FirstNumber + SecondNumber
End Function

We need now to compile the DLL. From the File menu choose "Make AdditionHelper.dll", this will compile the dll into a callable format. Save the DLL in a directory which you have choosen. If you have already saved the project or compiled the DLL it will save it by default in that directory.

That's it, we have done all that is necessary to complete our first ActiveX DLL. Now we need to set up our webpage to send and receive the information to the DLL and display the results.

Next


Sections

Section 1: Creating the Component
Section 2: Registering and Using the Component

The Bookworm
Search the Tutorial-Web library for books on any topic!
Sponsors

Search Now:
In Association with Amazon.com