Invalid Procedure Call or Argument to VB COM Component

D

Don Miller

In a classic ASP mode, I try to make a call on a public VB COM object
function/method like this:

Dim params(5) 'As Variant
params(0) = "test"
params(1) = ""
params(2) = ""
params(3) = 44
params(4) = 1168
params(5) = 5

Dim errorReport 'As String
Dim objErrorLog 'As Errors.ErrorLog
set objErrorLog = Server.CreateObject("Errors.ErrorLog")
errorReport = objErrorLog.writeError("Source of Error", "Error Description",
"Error Number", "Error Class", "Error Method", params)
Set objErrorLog = Nothing

The function is defined like this:

Public Function writeError(ByVal errSource As String, ByVal errDescription
As String, ByVal errNumber As String, ByVal component As String, ByVal
method As String, ByVal aParams As Variant) As String

However, I get the error message "Invalid Procedure Call or Argument" and
can't seem to figure out why.

Any ideas? Thanks.
 
B

Bob Barrows

Don said:
In a classic ASP mode, I try to make a call on a public VB COM object
function/method like this:

Dim params(5) 'As Variant
params(0) = "test"
params(1) = ""
params(2) = ""
params(3) = 44
params(4) = 1168
params(5) = 5

Dim errorReport 'As String
Dim objErrorLog 'As Errors.ErrorLog
set objErrorLog = Server.CreateObject("Errors.ErrorLog")
errorReport = objErrorLog.writeError("Source of Error", "Error
Description", "Error Number", "Error Class", "Error Method", params)
Set objErrorLog = Nothing

The function is defined like this:

Public Function writeError(ByVal errSource As String, ByVal
errDescription As String, ByVal errNumber As String, ByVal component
As String, ByVal method As String, ByVal aParams As Variant) As String

However, I get the error message "Invalid Procedure Call or Argument"
and can't seem to figure out why.

It's been years since I've dealt with this, but I seem to recall that
these articles were helpful:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;244012
http://support.microsoft.com/default.aspx?scid=kb;EN-US;197956

Building COM Components That Take Full Advantage of Visual Basic and
Scripting
http://msdn.microsoft.com/library/techart/msdn_vbscriptcom.htm
 
D

Don Miller

It's always Bob Barrows to the rescue!! It's been years for me as well (the
code works so well I rarely have to touch it) but I found the Array function
in VBScript which seems to fill the bill by returning a variant array (and
my function did require ByVal instead of ByRef).

Dim params
params = Array(null, null, null, 5, 24, 5)

Thanks.
 
D

Don Miller

Yes. Within the VB COM object all of my arrays are variants and are passed
ByVal as such but this didn't work with VBScript arrays. I solved the
problem by using the VBScript Array function which returns an array as a
Variant (couldn't find anything like CVariant to type the original array).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top