This is not a VB vs Delphi post - but I think Alexander is learning VB/ASP
at this time, so throwing another language into the mix is probably not
useful.

Creating a COM component in VB is extremely simple - just specify ActiveX
DLL (or ActiveX Exe) for the new project type.  Name the project something
meaningful.

In the component, define your procedures (Sub, Function, Property
Get/Let/Set) as Public if they are supposed to be accessible to users of the
component.  "Internal" procedures should be defined as Private.

The main thing you should think about is version compatibility for your
resulting COM component.  To maintain upgrade compatibility, follow these
guidelines:

1:  Spend a little bit of time defining what the (main) interfaces should
look like (project and class name(s), public procedure names, parameter
names, and their data types).

2:  After the FIRST successful compile, create a subdirectory
(.\Compatibility) and copy the compiled component (DLL or Exe) there.  In
your project, select Project > Properties, and go to the Component tab.
Select "Binary Compatibility" and type the (relative) path to the copy of
your DLL/Exe (Compatibility\MyDLL.DLL).

3:  NEVER make any CHANGES to an existing public procedure interface (i.e.
procedure name, type, or parameter names, types, or sequence, etc.).  Making
any such changes would break compatibility, and you'd basically wind up with
a new COM object that the system would consider "different".  If you find
that one of the interfaces needs a modification, instead add an additional
procedure with the proper parameters.  Compile the component and copy the
new version to the Compatibility subdirectory.

In order to use your component, you have to register it on the target
system.  Use the Package and Deployment Wizard or any other such tool at
your disposal to create a setup program for it.  If you don't know better,
use the defaults to get you started, and then test your setup on a "clean"
test PC.  I have found that using Drive Image [Pro] or a comparable app to
keep clean install images of different OS'es available for testing is a
great way to be able to do this.

In your ASP VBScript code, Access the component as follows:

...
Set objMyComponent =
Server.CreateObject("prjMyComponentTitle.clsMyClassName")
x = objMyComponent.MyFunction(p1, p2)
objMyComponent.MyProperty1 = y
z = objMyComponent.MyProperty2
Set objX = objMyComponent.MyObjectReturningFunction(p1, p2, p3)
Set objY = objMyComponent.MyObjectProperty
Set rsX = objMyComponent.MyRecordsetPropertyOrFunc[()]
...
'Clean up:
Set objMyComponent = Nothing
Set objX = Nothing
Set objY = Nothing
'To clean up most ADO objects:
If Not rsX is Nothing then
        If rsX.State = adStateOpen Then
                rsX.Close
        End If
        Set rsX = Nothing
End If


HTH,
Tore.


-----Original Message-----
From: Stephen Wood [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 17, 2002 8:24 AM
To: ActiveServerPages
Subject: RE: passing variables to a COM object.


Hey Nick, you got lucky I actually read this...haven't been focusing on this
group much...

I'll semi-back you up, COM is COM, and it's basically the same to write one
in any language, but where Delphi comes into it's own, is that you can do a
gazillion other things in your COM objects, for example, if you have a cool
Java applet, you could in fact in your COM object, create a VM instance,
execute your Java applet, and return something back to your client via
COM....(just as an example)...

-----Original Message-----
From: Nick Middleweek [mailto:[EMAIL PROTECTED]]
Sent: 17 September 2002 02:24
To: ActiveServerPages
Subject: RE: passing variables to a COM object.


Alexander,

I've never written a COM to return a RecordSet but I think the easiest way
to start with is to design your method so that it receives two parameters.

If you've not written COMs before I'd go and find some simple tutorials on
the Net. I know Sam Thompson found a few ages ago (in fact he's quiet these
days).

I would also strongly suggest (Stephen, back me up) using Delphi as your
development environment to create COM objects. Delphi's great!

I know it's frustrating because you know what you want it to do, you could
probably do it in VBScript with ease but taking that jump into another
'world' is a slow one. I wish I knew Delphi more, I'd be writing COMs every
week.

---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to