Invalid Procedure Call or Argument to VB COM Component

Discussion in 'ASP General' started by Don Miller, Aug 13, 2009.

  1. Don Miller

    Don Miller Guest

    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.
    Don Miller, Aug 13, 2009
    #1
    1. Advertising

  2. Don Miller

    Bob Barrows Guest

    Don Miller wrote:
    > 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


    --
    HTH,
    Bob Barrows
    Bob Barrows, Aug 13, 2009
    #2
    1. Advertising

  3. Don Miller

    Don Miller Guest

    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.

    "Bob Barrows" <> wrote in message
    news:...
    > Don Miller wrote:
    >> 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
    >
    >
    > --
    > HTH,
    > Bob Barrows
    >
    >
    Don Miller, Aug 13, 2009
    #3
  4. Don Miller

    Don Miller Guest

    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).

    "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
    news:...
    > perhaps because you trying to pass an array as a variant ?
    >
    >
    >
    Don Miller, Aug 13, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Java Guy
    Replies:
    1
    Views:
    665
    Manish Pandit
    Oct 15, 2006
  2. AlexWare
    Replies:
    2
    Views:
    740
    Paul Uiterlinden
    Oct 23, 2009
  3. Replies:
    1
    Views:
    162
    Phill. W
    Aug 11, 2005
  4. Matt

    Invalid Procedure Call or Arguement

    Matt, May 5, 2006, in forum: ASP General
    Replies:
    5
    Views:
    184
    Anthony Jones
    May 5, 2006
  5. Java Guy
    Replies:
    1
    Views:
    290
Loading...

Share This Page