Hi,

Sorry for the cross-post from the COM/COM+ board, but I'm interested to get
an answer:

I'm writing some subroutines and functions in a VB COM component that will
be used only by scripting clients (asp pages). I've done a lot of components
for VB clients, but I know there are significant differences in data typing
and error handling. I have some questions on this—I'd really appreciate what
advice people have

1) Data typing. Let's say for a binary client I'd write a function within
a COM component like this:

Public Function getData(ByVal lCustID As Long, ByVal sCustLastName As String)
As ADODB.Recordset

My first inclination for writing this same function for an asp client would
be to write it like this:

Public Function getData(ByVal vCustID As Variant, ByVal vCustLastName As
Variant) As Variant

But: can I keep the data typing (e.g., As Long, As String) as long as I'm
specifying ByVal? If I can, would the asp client be responsible for ensuring
matching data types? In other words, would the client's call have to look
something like this:
……..
Set oRS = oMyObject.getData(CLng(custID), CStr(custLastName))

(or would the client somewhere before calling have to ensure the variables
were correctly cast?)

2) Error handling and raising errors. I've heard that you should never raise
an error from a COM component back to asp, and then I've heard that you should
only never raise a user-defined error back to asp. My choice so far has been
not to raise any errors back, but when error info is needed, to pass something
back in a ByRef variable. So, my getData function above with error-data would
look something like this:

Public Function getData(ByVal vCustID As Variant, ByVal vCustLastName As
Variant, ByRef vErrMsg As Variant) As Variant

If the server (component) encountered an error, then it would populate vErrMsg
and the client would have to know to look at it.

Again, any ideas on best practices would be greatly appreciated!!

TIA,
Paul Klanderud